Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding LDAP authentication #658

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dru1d-foofus
Copy link

Potentially Fixes #316

I have been working to add LDAP authentication functionality for our particular environment and noticed there was an outstanding issue/feature request from 2018. We use starttls here and that might not be required for every LDAP configuration; however, I didn't have time to really expand upon those edge cases.

There have also been changes made to the UserAPI for enabling and disabling LDAP. I updated the .tex files, but didn't not generate new .pdfs or anything.

I'm not the most skilled developer and there will probably be bugs/better ways to accomplish the task, but I'm hoping this will help get the ball rolling.

@zyronix
Copy link
Member

zyronix commented Dec 20, 2020

I review the code and I managed to get it to work. So thanks for your contribution! Like you described, it has some limitations.
First of, when you want to use this module you need to install the php-ldap library. This should be mentioned somewhere.

Second, I guess you have been working with a ldap server that allows for 'username@domain' bind. This is mostly common for I guess a windows AD environment.

To make the code work with other LDAP servers the line:
$ldapbind = @ldap_bind($ldap_conn, $username."@".$domain, $password);

should be changed to:

$ldapbind = @ldap_bind($ldap_conn, "cn=".$username.",".$base_dn, $password);

Where 'domain' will be changed to 'Base DN'
An example:
'dc=example, dc=org'

this will make the code compatible with both active directory as well as with a linux ldap server.

Also an inclusion of an simple checkbox to check to either disable or enable TLS would be a minor change but a big plus.

So I would prefer some minor changes before we accept this pull request

  1. Doc update to show that additional php library is required
  2. make small change to make code work with non-ad ldap servers
  3. add options to support disabling TLS

@@ -134,7 +153,7 @@ public static function createUser($username, $email, $rightGroupId, $adminUser)
$newPass = Util::randomString(10);
$newSalt = Util::randomString(20);
$newHash = Encryption::passwordHash($newPass, $newSalt);
$user = new User(null, $username, $email, $newHash, $newSalt, 1, 1, 0, time(), 3600, $group->getId(), 0, "", "", "", "");
$user = new User(null, $username, $email, $newHash, $newSalt, 1, 0,1, 0, time(), 3600, $group->getId(), 0, "", "", "", "");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LINT: missing space after comma

@@ -0,0 +1,2 @@
Order deny,allow
Deny from all
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be part of this commit pull request?

(77, 1, 'hcErrorIgnore', 'DeviceGetFanSpeed'),
(78, 8, 'ldap_server', ''),
(79, 8, 'ldap_domain', '');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LINT: Too many newlines

@@ -57,6 +57,28 @@ <h2>User ([[htmlentities([[user.getUsername()]], ENT_QUOTES, "UTF-8")]])</h2>
</form>
{{ENDIF}}
</td>
</tr>
<tr>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LINT: Indentation does not match outer indentation

@gentoo9ball
Copy link

Any chance we can get this merged and a new release put out?? :) pretty please

@dru1d-foofus
Copy link
Author

My apologies! I didn't mean to drop this on your doorstep and bail. I have had other work commitments that took me in a different direction and I really don't have the bandwidth to finish what I started here.

I just wanted to to share a partial solution for an on-going feature request in hopes that it could help aid in development.

@zyronix
Copy link
Member

zyronix commented Aug 26, 2021

@gentoo9ball Could you test the branch of @dru1d-foofus? This help me to determine if the code is ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LDAP Authentication
4 participants