[Security] fixes LDAP bind authentication using wrong username#21588
Closed
haffmans wants to merge 1 commit intosymfony:3.2from
Closed
[Security] fixes LDAP bind authentication using wrong username#21588haffmans wants to merge 1 commit intosymfony:3.2from
haffmans wants to merge 1 commit intosymfony:3.2from
Conversation
This fixes that the LDAP bind authentication ignores the uid_key configuration of the LDAP user provider. It will now use the username of the User object instead of the token's username.
Member
|
ping @csarrazi |
Member
|
@csarrazi Can you have a look at this PR? Thanks. |
Contributor
|
This has already been fixed in the Also, the reason why we use the token's username is because we should not rely on the user provider to provide the username. This works fine when you are using the LDAP user provider, but it may fail should you use another user provider. E.g. If you want to authenticate using your LDAP server, but rely on the database to store user-related information. |
Member
|
@csarrazi Thanks for the quick feedback. So, can we close this one then? |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm trying to set up LDAP authentication where users can log in using their e-mail address, which should get resolved to the 'uid' field in the directory. After this the authentication should be based on this uid. I'm working against '389 directory server' as set up by a Kolab install. This does not seem to allow binding based on e.g. the mail field of a user.
The LDAP user provider is able to resolve the user. This is the (redacted) provider config I'm using:
I noticed the User object created by the LdapUserProvider is correctly set the the uid field of the user.
However, the LDAP Bind Authentication Provider does not use the username as provided by the user provider. Instead it uses the username as submitted in the token when binding. This means users cannot login.
The fix is to use
$user->getUsername()instead of$token->getUsername()incheckAuthentication(). This way the resolved username is used and the authentication works correctly.