-
Notifications
You must be signed in to change notification settings - Fork 2
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
Migrate to v2 of the ldap-module #12
Conversation
src/Auth/Source/X509userCert.php
Outdated
*/ | ||
public function findUserByAttribute(string $attr, string $value): ?Entry | ||
{ | ||
$searchBase = $this->ldapConfig->getString('search.base'); |
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.
Using getString here results in error: "The option 'search.base' is not a valid string value."
That's because option search.base for the LDAP module has changed from string to array.
The right method to call should be getArray; however, that creates more troubles on line 283 (see next comment).
src/Auth/Source/X509userCert.php
Outdated
Assert::nullOrnotWhitespaceOnly($searchPassword); | ||
|
||
$ldap = ConnectorFactory::fromAuthSource($this->backend); | ||
$ldapUserProvider = new LdapUserProvider($ldap, $searchBase, $searchUsername, $searchPassword, [], $attr); |
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.
Option search.base should be retrieved with getArray. That makes $searchBase an array of strings, while LdapUserProvider expects $searchBase to be a string.
A quick and dirty workaround, just for the sake of further testing, would be to pass $searchBase[0] (other base DNs to be searched are temporarily ignored).
I'm trying to setup this module on latest SimpleSAMLphp version (2.2.1) but I'm experiencing issues. Modules installed: Code fixes: Issues found:
|
b37852f
to
0aaf849
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12 +/- ##
============================================
- Coverage 14.86% 12.04% -2.82%
- Complexity 40 43 +3
============================================
Files 3 3
Lines 148 166 +18
============================================
- Hits 22 20 -2
- Misses 126 146 +20 |
Can you give it another try @kiokuj ? |
I confirm that the fix for search.base now works out of the box, thank you. There's still the main issue I reported, which boils down to this exception at X509userCert.php:284, when LdapUserProvider is instantiated: Here's the full error log:
|
That one should also be fixed now! |
Thanks! Definitely some progress (no more Symfony errors), but I'm still testing right now. I'm getting TypeError: array_merge(): Argument #2 must be of type array, null given at X509userCert.php:217. I'll try and see if it's related to my authsource or LDAP configuration. |
It would be good to know what the value of the |
I agree, $ldap_certs isn't definitely empty, otherwise I'd have seen the UNKNOWNCERT error ("authX509: no certificate found in LDAP"), but that's not supposed to be raised. Full debug log follows. Certificate attribute dnQualifier is mapped to uidNumber in authsource configuration, and the corresponding user seems to be found indeed in LDAP. I'll check the values of those variables and report back shortly.
|
OK, I'm back with some results. First of all, I believe there's a typo in X509userCert.php:205: the function call should be getAttributes (final 's'): Moving on, This seems to finally work (by the way, for my setup in authsources.php I had to set authX509:ldapusercert to userCertificate instead of the default userCertificate;binary). |
What kind of LDAP-backend are you using? MS Active Directory? |
Samba4 on Debian 12. |
The getAttribute/getAttributes seems correct to me.. I only want to fetch the specific ldap-attributes that contain a certificate.. getAttributes would fetch all attributes. The array access was fixed |
You're right, getAttribute is more efficient. I was misled by the However, I noticed that the array returned by getAttribute is no longer associative. Therefore X509userCert.php:217 should become |
That doesn't make sense, because that would make the foreach-statement useless.. |
Good point, but the array structure is different. Array
Array
As there is just one attribute, it seems that its name is not retained, and you just get its value(s). So there's apparently no place for I'm not sure what happens in the (rather exotic) case of multi-valued LDAP attributes (that is, if you have two or more certificate attributes, like userCertificate and otherUserCertificate, each of them with more than one binary value). The first structure is obviously strong enough to encode that scenario; I don't know what the second will become (not being an associative array). |
Could you please test my latest fix? |
It works, thank you! |
Thanks a lot for your help! I've just released v2.0.0 |
It was my pleasure! But there's one more issue... X509 authentication is completed successfully, however when I test that method from the admin page I only get the certificate attribute, and not also the other attributes taken from LDAP. In authsources.php I used to add the 'attributes' array, but now it seems ignored. Here's the relevant part of my authsources.php:
In addition, the documentation for the module should be updated... |
Can you verify that this solves your issue? btw, the attributes-array should go in the ldap-authsource, not in the x509 source. That should indeed be fixed in the docs. |
Yes, commit cac692a solves my issue. Indeed, I already put the attributes-array in the ldap-authsource. The duplicate attributes-array in the x509-authsource was probably a leftover from the previous version of authsources.php. |
Thanks again! Updated the docs and tagged v2.0.1 |
Glad to have helped. Keep up the good work! |
** Untested **
I need someone to verify this for me, because I'm unable to get certificate authentication to work in my sandbox.