CVS edit link for synodinos

Nodepal: A Drupal integration layer for Node.js developers

This is a module that allows the integration of a Drupal installation with a custom Node.js app. It provides an API so that Node.js developers can directly read and write in Drupal's repository, using constracts like node, user, permission, etc., with having to worry about the underlying implementation and setup of the Drupal installation.

CommentFileSizeAuthor
#9 nodepal.zip13.37 KBsynodinos

Comments

avpaderno’s picture

Component: Miscellaneous » miscellaneous
dave reid’s picture

Please provide the code you'd desire to commit to the drupal.org repository, licensed under GPLv2... before anyone can review it.

chx’s picture

And note that contrary to http://groups.drupal.org/node/121404#comment-395514 code does not need to be PHP. We happily host dreditor. And also drush which is not a Drupal module either (although PHP).

avpaderno’s picture

Actually, the CVS application is for modules, themes, and installation profiles. I would find difficult check other type of code against the Drupal coding standards. :-)

dave reid’s picture

There's nothing to say a module can't be PHP. We use modules for 'other' things like database drivers, drush, dreditor, etc.

avpaderno’s picture

@Dave Reid: The projects you list have not been created from users who applied for a CVS account and used those projects as proposed module for the application.

If we are going to accept every PHP file for an application, then we should be prepared to CVS applications where the proposed "module" is a third-party library (maybe GeShi, or a WordPress plugin, or a JavaScript plugin).
I think this needs to be discussed a little more, before to change what the current CVS application requirements report.

chx’s picture

I say, if someone wants to host connect-to-Drupal GPL v2+ code on Drupal.org they are most welcome regardless of the host system.

avpaderno’s picture

@chx: You approved a CVS application where the applicant provided a plain text file; it should have been declined just for the fact the text didn't contain any call to Drupal functions. ;-)

(I am joking.)

Anyway, this is not the place to discuss changes to the CVS application requirements.

synodinos’s picture

StatusFileSize
new13.37 KB

I attach a zip file with the code.

More details:

https://github.com/synodinos/nodepal &
http://groups.drupal.org/node/121404

Thanks,
Dio

avpaderno’s picture

Status: Postponed (maintainer needs more info) » Needs work

As per requirements, the motivation message should include more than two sentences (the exact words are a few paragraphs) that describe the project features. For themes, it should include also a screenshot of the theme (at least 640x400 pixels), and (when possible) a link to a working demo site; for modules, it should include also a comparison with the existing solutions.

synodinos’s picture

Motivation message:

This is a module that allows the integration of a Drupal installation with a custom Node.js app. It provides an API so that Node.js developers can directly read and write in Drupal's repository, using constructs like node, user, permission, etc., without having to worry about the underlying implementation and setup of the Drupal installation.

Use Cases:

  • You have a working Drupal installation, with users, content, etc. and would like to add real-time services like chat, etc. The usual Apache-PHP-MySQL setup might not the best suited for this kind of apps, so you can develop you app in Node.js and hook it up to your Drupal, using the Nodelpal integration layer.
  • You want to build a new Node.js app, that has some notion of users, roles, permissions or content and would like to use Drupal's user, roles, permissions, content model and its great administrative interface, without having to build everything from scratch.
  • You want to build a new Node.js app and combine it with Drupal because there is some Drupal module that you find useful. E.g. you can add a Drupal forum, a Blog, or expose some content as a Web Service, or search it with Apache Solr. There is a Drupal module for everything :)

At the time of this writing, Nodepal is:

  • Read-only
  • Works only with MySQL,
  • Provides a limited set of function (which can be easily extended),
  • Works only for Drupal v6 (but it's veru easy to go v7),
  • Doesn't work with memcache setups (wanna contribute?),

See demo.js. In order for it to work, you need both Node.js and Drupal on teh same domain in order to share the session cookie. Also you must first create a user in Drupal, who has both roles and permissions. After first login into Drupal (sessions cookie created), launch demo.js and see if your Drupal data are available in Node.js.

FAQ:

Q: Why not have a Drupal Module, directly serve JSON to Node.js?
A: Putting a PHP stack, between your data repository and Node.js might introduce a significant bottleneck. Nodepal is based on the idea that Node.js integrates with Drupal directly on the DB layer, for maximum performance!

Q: I need to read/write X from/to my Drupal installation but there is no function in the Nodepal API for that.
A: Drupal has a huge API and it's not possible to replicate it in Node.js. Nodepal aims to grow organically, adding new functionality, depending on what I need for my projects or what its users request. You can always develop your own functionality using the current as template, or open a ticket and I'll try to add it.

I'll try to keep track of 3rd party projects that are using Nodepal:

dave reid’s picture

exports.getField = function(client, nid, fieldName, callback) {
  var field = new Array();
  var fieldColumnName = "field_" + fieldName + "_value";
  client.query(
          'SELECT type FROM node WHERE nid=?',
          [nid],
          (function selectCb(err, results, fields) {
            if (err) {
              throw err;
            }
            for (result in results) {
              field[result] = results[result].type;
              client.query(
                      'SELECT ' + fieldColumnName + ' FROM content_type_' + field[result] + ' WHERE nid=?',

Is this going to allow SQL injection since it's not using placeholders? or escaping field or table names?

synodinos’s picture

The two variables that are not bound in the later SQL statement do not have anything to do with user input so it's unlike that they'll be the cause of an SQL injection. Good observation though!

owen barton’s picture

If you open MySQL access to site users (via Javascript), they can by definition run any query that MySQL GRANTs access to (either by hacking the Javascript, or just connecting with their favorite desktop MySQL client). Placeholders, type check etc in the JS are meaningless from a security point of view.

This suggests to me that the main question is: what table/column privileges are secure? This would need to be quite restrictive, and I think needs to be extremely explicitly documented with each callback.

This could be used to allow SELECTs of basic node content/fields, however this is on the condition that node_access is not used, and all site content is publicly readable. There is no way to build a node_access compliant system using this approach without adding MySQL views or stored procedures to enforce the node_access JOIN.

synodinos’s picture

@Owen

Regarding the privileges, do you suggest I added a comment on every functions that explains which privileges must be present?

Regarding being "node_access compliant", it is impossible to do so when going out of the PHP runtime and e.g. not having the ability to call/listen to hooks. This is outside of the scope of this project. The idea is that if a user needs more, e.g. would like to integrate with a module that provides privileges, then he creates his own function and contributes back :) This could be done e.g. for the ACL module or CCK.

This is the best it can get with DB-level integration and not Drupal API level integration, but the performance gains of a fully asynchronous stack are huge and in some use cases absolutely essential.

Charuru’s picture

@Owen
node.js is a server, not client. users do not have mysql access.

views are created on the server in node.js. It should be up to the developer of the node.js app to check for node_access.

Also, nodepal is an integration layer for developers, it's nothing that site administrators would be exposed to.

owen barton’s picture

This makes a lot more sense in that case - I think it would still need careful attention to security though.

synodinos’s picture

Should I be waiting for some kind feedback regarding this?

zzolo’s picture

Status: Needs work » Postponed

Hi. Please read all the following and the links provided as this is very important information about your CVS Application:

Drupal.org has moved from CVS to Git! This is a very significant change for the Drupal community and for your application. Please read the following documentation on how this affects and benefits you and the application process:
Migrating from CVS Applications to (Git) Full Project Applications

  • The status of this application will be put to "postponed" and by following the instructions in the above link, you will be able to reopen it.
  • Or if your application has been "needs work" for more than 5 weeks, your application will be marked as "closed (won't fix)". You can still reopen it, by reading the instructions above.
synodinos’s picture

Status: Postponed » Active

It's on Git now as "experimental" (http://drupal.org/sandbox/synodinos/1075892). Should I re-apply, or should I wait for further feedback?

Thanks!

zzolo’s picture

Status: Active » Postponed

Hi @synodinos. Great that you got that started. So, make sure you read up here as there are explicit instructions: http://drupal.org/node/1075406

Then if you feel you want to continue to Full Project access, then change the Project type of this issue. Please consider and read carefully. The more you refine your module and are familiar with Drupal best practices the quicker the application process can be. But, we still have the same capacity (all volunteer) to review projects, so we cannot promise a quicker review time at this moment.

Please note that I have not actually looked at your project yet, but just speaking general.

synodinos’s picture

Project: Drupal.org CVS applications » Drupal.org security advisory coverage applications
Status: Postponed » Needs review
tim.plunkett’s picture

Title: synodinos [synodinos] » Nodepal

updating title

sreynen’s picture

Component: miscellaneous » new project application
sreynen’s picture

Component: new project application » module
Status: Needs review » Needs work

Hi synodinos,

Since you opened this application, a new module has been created: Nod.js integration. At a quick glance, it looks like you're focusing more on the node.js side of the integration, and that module is focusing more on the Drupal side, so this might be a good opportunity for collaboration. Drupal.org heavily favors collaboration over having multiple projects with very similar goals. If collaboration won't work for some reason, please explain why.

I'm setting this to "needs work" awaiting your response. Please set it back to "needs review" when you decide whether you want to keep pursuing a separate project or contribute to the existing project.

tim.plunkett’s picture

Status: Needs work » Closed (won't fix)

Closing due to inactivity, feel free to re-open if this was a mistake.