[
https://issues.apache.org/jira/browse/KNOX-3487?focusedWorklogId=1048395&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1048395
]
ASF GitHub Bot logged work on KNOX-3487:
----------------------------------------
Author: ASF GitHub Bot
Created on: 20/Oct/26 08:51
Start Date: 20/Oct/26 08:51
Worklog Time Spent: 10m
Work Description: smolnar82 commented on code in PR #1454:
URL: https://github.com/apache/knox/pull/1454#discussion_r4323143878
##########
gateway-server/src/main/java/org/apache/knox/gateway/services/ldap/backend/LdapProxyBackend.java:
##########
@@ -261,9 +269,13 @@ public boolean isSupportedSearchBase(String searchBase) {
if (searchBase == null) {
return false;
}
- String searchBaseLowerCase = searchBase.toLowerCase(ROOT);
- return searchBaseLowerCase.endsWith(proxyBaseDn.toLowerCase(ROOT)) ||
- searchBaseLowerCase.endsWith(remoteBaseDn.toLowerCase(ROOT));
+ try {
+ Dn searchBaseDn = new Dn(searchBase);
+ return searchBaseDn.isDescendantOf(proxyBaseDn) ||
+ searchBaseDn.isDescendantOf(remoteBaseDn);
Review Comment:
`new Dn(searchBase)` has no SchemaManager, so RDN values are compared
case-sensitively (api-ldap-model 2.1.8: `Ava.equals` -> `Value.equals` ->
`upValue.equals(...)` when there is no AttributeType). The caller
(`UserSearchInterceptor`) passes `ctx.getDn().toString()`, which is the
user-provided form. So `-b 'ou=people,DC=Proxy,DC=com'`, or a remote base
configured as `DC=Example,DC=com` and queried as `dc=example,dc=com`, is
silently skipped and returns no backend results, even though these DNs are
equal under LDAP matching rules (`dc`/`ou`/`cn` use caseIgnoreMatch).
Suggest a schema-aware Dn (pass the SchemaManager or the normalized
`ctx.getDn()` from `UserSearchInterceptor`), or at least lowercase both sides:
Dn searchBaseDn = new Dn(searchBase.toLowerCase(Locale.ROOT));
return searchBaseDn.isDescendantOf(proxyBaseDn.toLowerCase(Locale.ROOT))
||
searchBaseDn.isDescendantOf(remoteBaseDn.toLowerCase(Locale.ROOT));
A mixed-case base in `testIsSupportedSearchBase` would cover it.
##########
knox-site/docs/service_ldap_server.md:
##########
@@ -232,12 +276,165 @@ knoxcli.sh create-alias my_backend_bind_password --value
<password>
If the alias may be created shortly after the configuration is loaded (for
example when a Kubernetes Secret and the configuration referencing it are
created together), set `gateway.ldap.backend.password.alias.retry.attempts` to
have Knox look up a missing alias again every
`gateway.ldap.backend.password.alias.retry.interval.ms` milliseconds before
giving up ([KNOX-3513](https://issues.apache.org/jira/browse/KNOX-3513)). Each
retry is logged at WARN; the ERROR is only logged once the retries are
exhausted. All missing aliases are retried together, so the LDAP service waits
at most attempts x interval while starting or reloading. The Knox CLI
(`knoxcli.sh`) never retries, so commands such as `create-alias` are not held
up by the missing alias.
+### Role Strategy
+
+The role strategy, selected with `gateway.ldap.roles.lookup.strategy`, is
where the [Roles Lookup Interceptor](#roles-lookup-interceptor-roleslookup)
gets its role data. The same strategy answers three questions:
+
+| Question | Used for |
+| :-
Issue Time Tracking
-------------------
Worklog Id: (was: 1048395)
Time Spent: 1h 40m (was: 1.5h)
> LDAP Proxy find all members of a role
> -------------------------------------
>
> Key: KNOX-3487
> URL: https://issues.apache.org/jira/browse/KNOX-3487
> Project: Apache Knox
> Issue Type: Improvement
> Components: Server
> Affects Versions: 3.1.0
> Reporter: David Han
> Assignee: David Han
> Priority: Major
> Fix For: 3.1.0
>
> Time Spent: 1h 40m
> Remaining Estimate: 0h
>
> When role lookup is enabled on the LDAP Proxy, the LDAP Proxy should be able
> to return all users that are assigned a role. E.g.,
> {code}
> ldapsearch -b 'ou=users,DC=proxy,DC=com' -s sub
> '(memberOf=cn=rolename,ou=groups,dc=proxy,dc=com)' '*'
> {code}
> This would require calling the roles lookup service to get the mapped users
> and groups for the given role. Then modifying the search filter to replace
> the rolename with the users and groups.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)