The Simple LDAP project is a set of modules to provide Drupal integration with an LDAPv3 server. It is an alternative to the Lightweight Directory Access Protocol (LDAP) module, with a much narrower set of features resulting in a much simpler administrative interface. The goal of the project is to provide very basic LDAP functionality which should cover most common use cases.

http://drupal.org/sandbox/bchavet/1845170

git clone --recursive --branch 7.x-1.x http://git.drupal.org/sandbox/bchavet/1845170.git simple_ldap

This is a Drupal 7 module.

Reviews of other projects:

http://drupal.org/node/1879222#comment-6899972
http://drupal.org/node/1898112#comment-6995478
http://drupal.org/node/1837812#comment-6995644

CommentFileSizeAuthor
#3 simple_ldap_pareview1.jpg246.34 KBcarwin
#3 simple_ldap_pareview2.jpg827.47 KBcarwin

Comments

parwan005’s picture

Status: Needs review » Needs work

Hi,

here are my responses to your manual review done:-
1) You are using variable_get in your module without mentioning its default value. Found it in simple_ldap_role.module line 78. Default value should also be set while using variable_get
2) simple_ldap_test.module file is empty

Also make sure to fix your ventrail issues here : http://ventral.org/pareview/httpgitdrupalorgsandboxbchavet1845170git

Thanks
Parwan

blc’s picture

Thanks for the review!

1) You are using variable_get in your module without mentioning its default value. Found it in simple_ldap_role.module line 78. Default value should also be set while using variable_get

According to api.drupal.org, the default $default is NULL, which is fine for all locations where I do not specify a default. (http://api.drupal.org/api/drupal/includes%21bootstrap.inc/function/varia...)

2) simple_ldap_test.module file is empty

This is by design. simple_ldap_test is a hidden module that serves as the glue to enable SimpleTest in the other simple_ldap* modules. This hidden module is needed because in order to run tests, a real LDAP server is needed, along with some known entries. simple_ldap_test provides a location to configure this. I will add some text at the top of that file to explain.

3) Also make sure to fix your ventrail issues

I am reviewing the ventrail issues you linked to. I used drupalcs to verify coding standards, but the report I get does not match what your report shows. I even tried the latest 7.x-2.x branch of coder with no change. I'm not sure what is up there, but your report looks right according to the drupal coding standards documentation, so I will keep digging. I certainly want to make sure I have an accurate set of dev tools.

I can comment on the first section of the report, though. These functions are overridden from password.inc as described here: http://api.drupal.org/api/drupal/includes%21password.inc/7, so the function names cannot be changed. simple_ldap_user needs to handle passwords in plain-text in order to properly encrypt and send to the LDAP server. Password.inc is the only location that this can be intercepted.

Thanks again, more information to come after further review.

carwin’s picture

StatusFileSize
new827.47 KB
new246.34 KB
README.txt
The README on this project is actually really useful, the only thing I'd suggest is adding a module description to it.
project page
Check.
Master Branch
Nope, not using it.
Major coding standards / best practice issues
A run through of the module and submodules in this project via Coder returned the following: 266 passes, 124 fails, 99 exceptions, and 92 debug messages.
A run through of the module and submodules in this project via PAReview.sh returned: Severity minor, Drupal Commenting Standards, Internationalization, Drupal Security Checks, Drupal SQL Standards, Drupal Coding Standards.
See attachments for more details.
License
Not present, Check!
access administration vs. administer site configuration
Permissions make sense.
files[] without classes or interfaces
Files present in simple_ldap.info declare classes, no issues.
PAReview: 3rd party code
No 3rd party stuff here.
Multiple Applications
Nope, you're all set.
Already Approved
Nope, but I bet you will be soon.
Idle Application
Nope, you're all set.
Code too short
Nope, you're all set.

The Coder results are gigantic, so you'd probably be better off just running it through yourself. Most of it seems related to the tests failing. I'm attaching a link to the screenshot because it's too big for d.o: https://docs.google.com/open?id=0B2ENsfpXRywVU3JSWlFjWDNGQ0U

The PAReview.sh / ventral results have been addressed in your last comment, but I'm attaching screenshots here to keep things all in one place as much as possible. Coder and similar dev tools aren't always perfect.

I scanned the files pretty quickly and didn't notice any outstanding coding style errors. This could probably use a security check from someone more qualified than I.

q0rban’s picture

I can comment on the first section of the report, though. These functions are overridden from password.inc as described here: http://api.drupal.org/api/drupal/includes%21password.inc/7, so the function names cannot be changed. simple_ldap_user needs to handle passwords in plain-text in order to properly encrypt and send to the LDAP server. Password.inc is the only location that this can be intercepted.

Yes, what you have done there is perfect, blc. Also, these are the same findings that @carwin posted in his first attachment, so they can be disregarded there as well.

1) You are using variable_get in your module without mentioning its default value. Found it in simple_ldap_role.module line 78. Default value should also be set while using variable_get

As @blc mentions, the default value is NULL in Drupal 7, and it isn't necessary to explicitly specify. That was only the case in Drupal <= 6.

A couple of other things to note.

  1. It looks like you are exposing your own hook, called hook_sync_to_ldap. It's a common practice to add a mymodule.api.php file that documents how this hook might be used. For an example, you might look at Views module.
  2. The README file documents the class structure, which also might be good to go in the api file. README's typically are instructions on how to get the module set up, things to know, etc. You might document how to get a testing environment set up in there, how to specify the user map in settings.php, etc.
  3. I mentioned this before, but I don't see a lot of error detection going on. I would try to find where the best places are to wrap things in try {} catch () {}, and then log caught exceptions to the watchdog. One way to do that is to use the __call() magic method, and make all of your real class methods private and prefixed with an underscore. Then, in __call(), you can do:
      public function __call($name, $arguments) {
        $function_name = "_$name";
        if (method_exists($this, $function_name)) {
          try {
            return call_user_func_array(array($this, $function_name), $arguments);
          }
          catch (SimpleLdapException $e) {
            watchdog(__FILE__, (string) $e, array(), WATCHDOG_ERROR);
          }
        }
      }
    
  4. This is by no means necessary to get this module approved, but I would love to have a debug mode for this module, that prints things like the query made to ldap, the raw response, etc. to drupal_set_message, or watchdog or something.
  5. Again, by no means necessary, but you might consider adding hook_requirements implementation if certain required variables are not set properly, such as the password_inc variable, the user map variable, and basic things like checking to make sure the site can connect to the LDAP server successfully.

Overall, this module is a fantastic alternative to the existing LDAP module. Whereas the current LDAP module errs on the side of flexibility, this module, true to its name, errs on the side of simplicity. In my opinion, there need be no discussions in this issue of trying to combine these modules, or work together as maintainers, as they have fundamentally different goals, and trying to make the one marry to the other would end up losing what is good about either project.

The code in this module is immaculate, and speaks to the care and attention to detail that @blc has given this module. In addition to having a solid object oriented API, there are simpletests for every critical aspect of the module, such as user authentication, role creation/deletion, password security, and the list goes on.

We are using this module in a production environment that has 7000+ users with success. In addition, @blc has been very responsive and quick to fix issues as they've arisen.

All in all, this project gets one HUGE +1 from me. I don't think any of the above issues need to be addressed before this module gets approved. There are modules currently in contrib that don't hold a candle to the quality of work already present in this module (including my own), and everything mentioned above is just icing on the cake. Great work, @blc!

blc’s picture

I've fixed everything in the ventral report as possible, here are my justifications for the remaining items. http://ventral.org/pareview/httpgitdrupalorgsandboxbchavet1845170git

./simple_ldap_user/simple_ldap_user.password.inc: all functions should be prefixed with your module/theme name to avoid name clashes. See http://drupal.org/node/318#naming

This was mentioned on in #2. These functions are part of password.inc, which was overridden, and cannot be renamed.

sites/all/modules/pareview_temp/./test_candidate/simple_ldap_user/simple_ldap_user.password.inc:
+154: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
+164: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
+166: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
+179: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
+184: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
+235: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
+238: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
+245: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
+291: [minor] in most cases, replace the string function with the drupal_ equivalent string functions

Same as above. I copied password.inc from core, and made a few conditional additions to handle LDAP encryption. The items ventral is complaining about is core code, which I am not going to change.

FILE: ...tes/all/modules/pareview_temp/test_candidate/SimpleLdapServer.class.php
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
101 | ERROR | Line indented incorrectly; expected 8 spaces, found 6
--------------------------------------------------------------------------------

This is a comment, doesn't make sense to indent 8 spaces:

 98       case 'error':
 99         return ldap_errno($this->resource);
100
101       // Handle PHP ldap options.
102       case 'LDAP_OPT_DEREF':
103       case 'LDAP_OPT_SIZELIMIT':
104       case 'LDAP_OPT_TIMELIMIT':
FILE: .../pareview_temp/test_candidate/simple_ldap_user/SimpleLdapUser.class.php
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
230 | WARNING | The use of private methods or properties is strongly
| | discouraged, use "protected" instead
--------------------------------------------------------------------------------

This property is intentionally private because it handles passwords. It needs to be write-only, even to extending classes (security). This is documented in the code as well.

juampynr’s picture

Agree with @q0rban about the REAME.txt contents. These should be moved to simple_ldap.api.php. There are some tips about what should README.txt files have at http://drupal.org/node/447604.

The simple_ldap_role README.txt is empty, while the contents of simple_ldap_user's README.txt should be moved to simple_ldap_user.api.php.

Aren't here any libraries or extensions that this module needs? If so, implementing hook_requirements() would ensure they are met.

There is a small typo at SimpleLdapSchema

  /**
   * Return a lis tof attributes defined for the objectclass.
   */

simple_ldap_role.test misses some docblocks at the top of some of the test classes.

Looking at simple_ldap_user.password.inc, I see several functions that do not follow the modulename_function pattern, which could cause collisions. Is there a reason for that? Besides, aren't Drupal's password and hashing functions useful for this scenario?

These are very simple fixes and questions. The module looks very robust overall. Nice work!

blc’s picture

It looks like you are exposing your own hook, called hook_sync_to_ldap. It's a common practice to add a mymodule.api.php file that documents how this hook might be used. For an example, you might look at Views module.

Done.

The README file documents the class structure, which also might be good to go in the api file. README's typically are instructions on how to get the module set up, things to know, etc. You might document how to get a testing environment set up in there, how to specify the user map in settings.php, etc.

Done.

I mentioned this before, but I don't see a lot of error detection going on. I would try to find where the best places are to wrap things in try {} catch () {}, and then log caught exceptions to the watchdog. One way to do that is to use the __call() magic method, and make all of your real class methods private and prefixed with an underscore. Then, in __call(), you can do:

http://drupal.org/node/1847214

According to the OO coding standards doc (http://drupal.org/node/608152) prefixing class functions with an underscore is a no-no. I do want to throw exceptions, though. And it has been on my radar, but all of the LDAP functions return FALSE on error, which is what I am currently checking for. So, there is error detection, but it is very basic at this point.

This is by no means necessary to get this module approved, but I would love to have a debug mode for this module, that prints things like the query made to ldap, the raw response, etc. to drupal_set_message, or watchdog or something.

http://drupal.org/node/1847220

Again, by no means necessary, but you might consider adding hook_requirements implementation if certain required variables are not set properly, such as the password_inc variable, the user map variable, and basic things like checking to make sure the site can connect to the LDAP server successfully.

Done.

blc’s picture

Status: Needs work » Needs review
blc’s picture

Priority: Normal » Major

No activity for 2 weeks. Bumping priority per the guidelines at http://drupal.org/node/539608

juampynr’s picture

Status: Needs review » Reviewed & tested by the community

Based on the above reviews and fixes, I am marking this as RTBC.

carwin’s picture

Bump for RTBC, I can't find anything wrong with this.

klausi’s picture

We are currently quite busy with all the project applications and I can only review projects with a review bonus. Please help me reviewing and I'll take a look at your project right away :-)

blc’s picture

Issue summary: View changes

Add a pareview reference

blc’s picture

Issue summary: View changes

review bonus

blc’s picture

Issue tags: +PAreview: review bonus

Reviews added to the summary

jthorson’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contribution, blc!

I updated your account to let you promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and get involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

Thanks to the dedicated reviewer(s) as well.

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

review bonus