Fixed #19518 - added support for SASL LDAP - #19556
Conversation
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| CodeStyle | 1 minor |
🟢 Metrics 19 complexity
Metric Results Complexity 19
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
uberbrady
left a comment
There was a problem hiding this comment.
This feels like a large amount of changed code for something ought to be as simple as "...and if you enter no username nor password, but you have a certificate, try using that." I don't even think you need a new field for that. And I definitely don't think we should be using the ldap_sasl_bind() function, which only has stub documentation here: https://www.php.net/manual/en/function.ldap-sasl-bind.php. I think you should be able to keep using ldap_bind() as it was without any modification. I do think that something probably should change in the LdapTroubleshooter to handle the null-username (and/or null-password) cases.
According to the PHP documentation for ldap_bind -
If password is not specified or is empty, an anonymous bind is attempted. The dn can also be left empty for an anonymous bind. This is defined in https://tools.ietf.org/html/rfc2251#section-4.2.2
Once we have a new take for this, I can test against our own Google Workspace setup trying a password-less certificate to make sure that it works as intended.
| $identityLabel = 'the SASL EXTERNAL client certificate'; | ||
| } else { | ||
| $bind_results = ldap_bind($conn, $username, $password); | ||
| $identityLabel = $username; |
There was a problem hiding this comment.
I think this would be better as:
$identityLabel = " as $username";And then pulling the as $identityLabel below. And changing the $identityLabel for when $username is null to " using the SASL EXTERNAL client certificate". Then it would end up saying:
WARNING: Failed to bind to $ldap_url as $username
or
WARNING: Failed to bind to $ldap_url using the SASL EXTERNAL client certificate
|
Yeah, I can kill the checkbox, that's fair. Cert + key + blank uname/pword should be enough to auto-detect. 🤞 I don't think empty-cred Sparse PHP docs on Here's my counter-proposal:
What say you? |
|
I'm grumpy about it, but if (and only if) I really cannot get it to hook up with a "regular" ldap_bind, then I'll be OK with it (-ish). But once you have a re-worked PR, I can try and fiddle with it and see if we really do need that method for it to work. If we don't, then I'd love to not use it. |
|
Okay Mr. Grumpy Pockets. Go ahead and empty those grumpy pockets and pull down this branch and give it a go when you get a moment. |
This adds an opt-in Use SASL EXTERNAL bind toggle to the LDAP wizard so Snipe-IT can authenticate to a directory with the client TLS cert / key already configured on step 1, instead of a bind DN + password. Fixes #19518.
This (should?) enable Google Workspace LDAP and other directories that use mTLS certificate authentication.
Summary
ldap:troubleshootartisan command routes toldap_sasl_bind()in the same shape.--ldap-searchpreview emits-Y EXTERNAL(dropping-x/-D/-w) so operators can copy-paste the shell equivalent.(Note: The
-Yflag specifies the SASL mechanism to be used for authentication. If it's not specified, the program will choose the best mechanism the server knows.)Testing
php artisan ldap:troubleshoot --ldap-searchwith SASL EXTERNAL on and confirm the ldapsearch uses-Y EXTERNALinstead of-x -D … -w ….php artisan ldap:troubleshootand confirm Stage 4 admin bind + Stage 5 informational bind both succeed via SASL EXTERNAL.