-
Notifications
You must be signed in to change notification settings - Fork 458
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow. Thank you for taking the time to work on this old issue. However, can I convince you to wait until v3 is released? Most of this work is happening in lib/messages/
and I am currently quite deep into splitting that out to https://github.com/ldapjs/messages.
Client.prototype.saslBind = function saslBind (token, | ||
controls, | ||
callback, | ||
_bypass) { | ||
if (typeof (token) !== 'string' && !Buffer.isBuffer(token)) { | ||
throw new TypeError('token (string or Buffer) required') | ||
} | ||
if (typeof (controls) === 'function') { | ||
callback = controls | ||
controls = [] | ||
} else { | ||
controls = validateControls(controls) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather the function accept an input object so that positional parameter inspection is unnecessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you talking about an incopatible change also for client.bind()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This is a completely new method. There is no reason to carry forward difficult to maintain patterns.
* @param {Function} callback of the form f(err, res). | ||
* @throws {TypeError} on invalid input. | ||
*/ | ||
Client.prototype.saslBind = function saslBind (token, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we able to add a corresponding test for this in `client.test.js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
When will v3 happen? |
Dates are not promised. I will say that I had hoped to have it out before the new year, but there's always something else popping up in this codebase that makes estimates like that difficult. As an example, it turns out that the |
So I'd say I leave my PR as is and wait for the v3. Then I'll create new PRs to this and the messages repo. Feel free to tag this PR accordingly. |
Note: There are two issues I've noticed when bringing this to "production":
|
I am trying to setup a mock service for my work and I would also need the server side SASL support. Any chance to have it anytime soon? |
|
Since I have currently no idea how the formula for this challenge-response is, I'm unable to implement it. |
I'm hesitant to suggest this, because it technically means the org should be supporting it going forward, but I'm willing to compromise and merge it to the v2.x branch with the understanding that it will not be ported to v3 by myself (or @UziTech). |
For what it's worth, #834 was the biggest blocker for v3. Now that it is out there, progress should be quick. |
👋 On February 22, 2023, we released version 3 of this library. As a result, we are closing this issue/pull request. Please see issue #839 for more information, including how to proceed if you feel this closure is in error. |
I've added a working sasl (NTLM/GSSAPI) authentication. I've tested this successfully against ActiveDirectory. Also Wireshark shows that the produced messages are fine.
The client got a new method called
saslBind
, which takes one parameter which is the token that the browser submits in theAuthorization: NTLM <token>
header.Important to note is, that one needs keepAlive, since we have to subsequent requests to the LDAP server, which need to be on the same connection. Otherwise the second request (type3) wont be recognized by the LDAP server.
I've also prepared a patch for typescripts type definititions to include the new saslBind-Method. I'll push that as soon this PR gets approved.
An authorization middleware for Express might look like this, sorry this is typescript. One would most likely mix this with code that hands out a JWT upon successfull authentication. Further requests by the client should then be authnticated using that JWT, als long as it remains valid.
What I do not yet know if one needs to have one ldapjs-Client per user connection. I imagine that there could be problems when two users try to authenticate at the same time. So, worst case scenario is that one needs to keep unique instances of ldapjs per authenticating user at hand. After authencation is finished these instances can be recycled. Though, I have a hard time simulating this.
Additionally here is the most basic typescript Express app where it could be used: