-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
ActiveDirectoryLdapAuthenticationProvider does not implement support for multiple urls #7760
Comments
Happy to open a PR for this if someone from spring team can confirm how they would like this to be fixed? Below are the three suggestions I could think of;
In all of the three suggestions the field url type will be changed from String to list of String. The |
@setu9760 Did you try to pass in a space-separated list, e.g. "ldaps://dc1.mycompany.com:636 ldaps://dc2.mycompany.com:636"? Based on https://docs.oracle.com/javase/jndi/tutorial/ldap/misc/url.html:
|
I can confirm that @tvirtualw is correct regarding space-separated list. I have just now tested it. I configured two working ldaps urls, and then started to block them out in my However this should probably be better documented and maybe comma separated list aka array/list is a more natural way to handle multiple values than space-separated seen from/with "Spring eyes". |
The Javadoc today says:
This could change to "(or multiple space-delimited URLs)". The Javadoc could also link to https://docs.oracle.com/javase/jndi/tutorial/ldap/misc/url.html to clarify where the contract comes from. I hesitate to take a collection as that would bump the number of constructors from 2 to 4. It also deviates from the other APIs in Spring Security LDAP that take a space-delimited set of URLs as a parameter. Either way, that should be a discussion for another ticket since it will probably involve more components than just the authentication provider. Can someone submit a PR that updates the Javadoc? |
Got a bit puzzled by the fact that Raised a PR #15409 to update the javadocs. |
Summary
The javadoc for
ActiveDirectoryLdapAuthenticationProvider
constructors says the paramurl
supports multiple URLs. The javadoc however does not define how the multiple URLs needs to be supplied (i.e delimiter specification). Upon trying to supply this param as multiple URLs as a comma or pipe separated list this string is used as is during the ldap bindingActual Behavior
By looking at the code, specifically the constructors of
ActiveDirectoryLdapAuthenticationProvider
and methodbindAsUser
it uses the url provided in the constructor as is without checking if multiple URLs are present. Due to this the the lineenv.put(Context.PROVIDER_URL, bindUrl);
inbindAsUser
method will inject the list of URLs without splitting in the env which will be incorrect and the ldap bind does not work.Expected Behavior
The code should check if the supplied param url is a delimited list or URLs and then store it as such. During the authentication if an ldap server is unavailable the remaining URLs should be tried. The javadoc/code should also make it clear that if multiple URLs are to be supplied what format they should be in or there should be an additional constructor/setter that accepts list instead of a string.
Configuration
Version
spring-security-ldap 4.2.10 and 5.1.5.RELEASE
Sample
The text was updated successfully, but these errors were encountered: