Repository navigation
KNOX-3594: Populate role members on the LDAP all-groups search - #1529
Merged
Merged
Conversation
Answer an all-groups (role listing) search that requests the member attribute with each role's members: the users directly assigned to the role plus the user members of the groups assigned to it. A listing that does not request member still short-circuits to the bare role list and issues no further searches. Member resolution runs as sub-searches carrying the RolesLookupBypassControl so the backend groups and users are returned as-is rather than remapped to roles, and it leaves the caller's search context untouched. Directly-assigned users and the group members are resolved to directory user entries in a single user-base search, and only members that resolve to a user entry (objectClass inetOrgPerson) become role members, so group DNs never leak into a role's member list. The LDAP proxy backend flattens nested groups into their transitive members so the interceptor sees a group's full user membership. Nested members are classified authoritatively by object class rather than by DN location: each recursion level issues one batched search that matches the level's candidate DNs and restricts to the group object classes, so the server returns only the candidates that are actually groups. This stays correct when users and groups share a container (a group DN under the user search base would otherwise be mistaken for a user and not expanded) while fetching only the groups. Member and user DNs are normalized through the schema before comparison, since a user entry returned by the proxy backend may carry a DN that is not schema-normalized the way a member DN built via the schema is; without this the forms never match and every group-derived member is dropped. Two further guards cover DNs whose RDN attribute the schema does not know: the user filter is not issued with an empty OR, and DN normalization falls back to a schema-less structural normalization before a raw lowercase string. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Test Results 5 files 5 suites 1m 21s ⏱️ Results for commit 2d1adb7. ♻️ This comment has been updated with latest results. |
Review follow-ups to the role-member population work: - Seed the nested-group cycle guards with the group's own DN so a nested group that references it back does not make the group a member of itself. - Merge nested members into whichever membership attribute the entry already uses (member or uniqueMember) instead of always member, so a groupOfUniqueNames keeps a single uniqueMember list. - Memoize DN normalization per request in the roles interceptor so each member DN is rebuilt through the schema only once across resolveUsers and retainUserMembers. - Clarify in the docs that a role listing returning all user attributes (no attribute list, or *) also populates member, not only an explicit request. - Strengthen the cycle test and add a uniqueMember expansion test (isolated containers so existing member counts are unaffected); both fail without the backend fix. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
KNOX-3594 - A short description of the change
What changes were proposed in this pull request?
Answer an all-groups (role listing) search that requests the member attribute with each role's members: the users directly assigned to the role plus the user members of the groups assigned to it. A listing that does not request member still short-circuits to the bare role list and issues no further searches.
Member resolution runs as sub-searches carrying the RolesLookupBypassControl so the backend groups and users are returned as-is rather than remapped to roles, and it leaves the caller's search context untouched. Directly-assigned users and the group members are resolved to directory user entries in a single user-base search, and only members that resolve to a user entry (objectClass inetOrgPerson) become role members, so group DNs never leak into a role's member list.
The LDAP proxy backend flattens nested groups into their transitive members so the interceptor sees a group's full user membership. Nested members are classified authoritatively by object class rather than by DN location: each recursion level issues one batched search that matches the level's candidate DNs and restricts to the group object classes, so the server returns only the candidates that are actually groups. This stays correct when users and groups share a container (a group DN under the user search base would otherwise be mistaken for a user and not expanded) while fetching only the groups.
Member and user DNs are normalized through the schema before comparison, since a user entry returned by the proxy backend may carry a DN that is not schema-normalized the way a member DN built via the schema is; without this the forms never match and every group-derived member is dropped. Two further guards cover DNs whose RDN attribute the schema does not know: the user filter is not issued with an empty OR, and DN normalization falls back to a schema-less structural normalization before a raw lowercase string.
How was this patch tested?
Added Unit tests, Integration tests.
Performed manual tests against Active Directory with File-based roles lookup configured. The roles assignments were arbitrarily generated using the users and groups from AD.
submitted search requests w/o
memberattribute:The results come back very quickly since the data is from the roles service only.
Also searched with
memberrequestedThis takes longer because LDAP searches are submitted to retrieve the user members of each group assigned to a role. Recursive groups are configured in the backend that flattens nested groups to depth 3.
Integration Tests
Integration tests were added to the
test_knox_ldap_proxy_search_with_role_lookup.pyfile, which run during thedocker-compose.role-lookup.ymlanddocker-compose.role-lookup-rest.ymlUI changes
No UI changes