Skip to content

Normalize LDAP user DNs (downcase and remove excess spaces)

username-removed-1144264 requested to merge mk-clean-ldap-user-dns into master

What does this MR do?

Normalizes LDAP user distinguishing names by downcasing and removing excess spaces around attribute names and values.

TODO

Are there points in the code the reviewer needs to double check?

I cleaned auth_hash.uid for LDAP auth_hash's instead of only cleaning specific usages of auth_hash.uid (like when setting an identity's extern_uid.) This should be safe since our system should always work with normalized DNs, and LDAP providers should always compare DNs according to LDAP spec.

This should cover more cases where we might otherwise improperly compare DNs. And this requires fewer references to cleaning DNs that we need to maintain and add (when new comparisons of DNs arise).

Why was this MR needed?

There are rules in LDAP that allow different string representations of DNs to be equal (i.e. spaces around attribute names and values should be ignored).

So anywhere we compare DNs as strings (e.g. when syncing a group with its LDAP provider, or when looking up an Identity in our DB, etc.), we should compare them in some normalized form.

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes https://gitlab.com/gitlab-org/gitlab-ee/issues/3151

Edited by username-removed-1144264

Merge request reports