KNOX-3277 : LDAP Proxy improvements for working with AD backend#1177
KNOX-3277 : LDAP Proxy improvements for working with AD backend#1177smolnar82 merged 2 commits intoapache:masterfrom
Conversation
The LdapProxyBackend and GroupLookupInterceptors are updated to work with sAMAccountName in addition to uid and cn for user and group lookup. This involved adding the memberOf and sAMAccountName attribute types to the schema used by the proxy. Group retrieval during user search is fixed to respect the useMemberOf flag. Tests for the LdapProxyBackend were added.
Test Results7 tests 7 ✅ 1s ⏱️ Results for commit 6d253d4. ♻️ This comment has been updated with latest results. |
moresandeep
left a comment
There was a problem hiding this comment.
Thank you @handavid for the PR! looks great, I have few questions, if you can answer them that'd be great!
...way-server/src/main/java/org/apache/knox/gateway/services/ldap/backend/LdapProxyBackend.java
Show resolved
Hide resolved
...way-server/src/main/java/org/apache/knox/gateway/services/ldap/backend/LdapProxyBackend.java
Show resolved
Hide resolved
| private LdapBackend backend; | ||
| private static final Pattern UID_PATTERN = Pattern.compile(".*\\(uid=([^)]+)\\).*"); | ||
| private static final Pattern CN_PATTERN = Pattern.compile(".*\\(cn=([^)]+)\\).*"); | ||
| private static final Pattern SAMAACCOUNTNAME_PATTERN = Pattern.compile(".*\\(sAMAccountName=([^)]+)\\).*"); |
There was a problem hiding this comment.
I think this SAMAACCOUNTNAME_PATTERN should be case-insensitive. This is what the MS docs say about cases for attribute names https://learn.microsoft.com/en-us/windows/win32/ad/characteristics-of-attributes.
Perhaps we need something like (?i) (not tested, used Gemini :) )
private static final Pattern SAMAACCOUNTNAME_PATTERN = Pattern.compile("(?i).*\\(sAMAccountName=([^)]+)\\).*");
There was a problem hiding this comment.
There's a name normalizing filter somewhere in the interceptor chain prior to this point. The filter will have the normalized sAMAccountName string.
renamed "Entity" to "Entry" in LdapProxyBackend. rethrow exception caught when copying attributes.
|
@moresandeep I've updated the PR based on your comments. Thanks! |
moresandeep
left a comment
There was a problem hiding this comment.
Thanks @handavid the PR looks good. Thank you for your contribution to Knox!
...way-server/src/main/java/org/apache/knox/gateway/services/ldap/backend/LdapProxyBackend.java
Show resolved
Hide resolved
|
Thanks, @handavid, for your contribution. |
@smolnar82 After building knox, I ran the following commands to install and start the test gateway I then tested using |
|
Thanks, @handavid, this is very useful! |
KNOX-3277 LDAP Proxy improvements for working with AD backend
What changes were proposed in this pull request?
The LdapProxyBackend and GroupLookupInterceptors are updated to work with sAMAccountName in addition to uid and cn for user and group lookup. This involved adding the memberOf and sAMAccountName attribute types to the schema used by the proxy.
Group retrieval during user search is fixed to respect the useMemberOf flag.
Tests for the LdapProxyBackend were added.
How was this patch tested?
Changes were manually tested by running
ant start-test-gatewayconfigured against both AD and the test LDAP server.Unit tests were added to cover the LdapProxyBackend behavior.