fix(ldap-auth): key the consumer lookup on the escaped bind DN - #13805
Open
shreemaan-abhishek wants to merge 2 commits into
Open
fix(ldap-auth): key the consumer lookup on the escaped bind DN#13805shreemaan-abhishek wants to merge 2 commits into
shreemaan-abhishek wants to merge 2 commits into
Conversation
ldap_authenticate already returns the bind DN with the username escaped per RFC 4514. The plugin discarded it and rebuilt the same string by raw concatenation, so an entry whose RDN value carries a DN delimiter bound against one DN and was looked up under another.
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.
Description
ldap_authenticate()returns the bind DN it assembled as its third value, with the username escaped per RFC 4514 §2.4. The plugin discarded that value and rebuilt the same string by raw concatenation:The two forms diverge as soon as the username carries a character that has structural meaning in a distinguished name (
,+=<>;"\). An entry whose RDN value holds a comma binds againstcn=comma\,user,ou=users,dc=example,dc=org, a single RDN, and is then looked up undercn=comma,user,ou=users,dc=example,dc=org, a two-component path. So the request either matches no consumer or matches one that belongs to a different directory entry.This PR uses the DN the client already produced instead of rebuilding it, which keeps the bind target and the consumer key the same string by construction.
Backward compatibility: a consumer whose
user_dnwas written in the unescaped form to match the previous behaviour stops matching. This only affects directory entries whose RDN value contains one of the characters above, and the doc note added here spells out the escaped form to use. Every DN without those characters is unchanged.Tests: the CI directory fixture gains an entry whose
cnvalue iscomma,user. Two cases assert that a consumer keyed on the escaped DN matches and one keyed on the raw expansion does not.Which issue(s) this PR fixes:
Fixes #
Checklist