Sandor Molnar created KNOX-3622:
-----------------------------------

             Summary: KnoxIDF: allow the LDAP user params lookup to use the 
Knox LDAP service
                 Key: KNOX-3622
                 URL: https://issues.apache.org/jira/browse/KNOX-3622
             Project: Apache Knox
          Issue Type: Improvement
          Components: KnoxIDF, LDAP
            Reporter: Sandor Molnar
            Assignee: Sandor Molnar
             Fix For: 3.1.0


Today the KnoxIDF LDAP user params provider ({{LdapUserParamsProvider}}) always 
opens its own JNDI connection. It needs separate configuration: 
{{user.params.provider.ldap.url}}, {{systemUser}}, {{systemPasswordAlias}}, 
{{userSearchBase}}, {{groupSearchBase}}, and so on. In production this usually 
points back at Knox's own embedded LDAP server. The same backend is then 
configured twice, and every lookup does a network bind and search against our 
own process.

{{HadoopGroupProvider}} already avoids this with {{use.ldap.service=true}}, 
which resolves groups in-process through {{KnoxLDAPService}}. KnoxIDF should 
offer the same option.

*Proposed changes*
* Add a {{lookupUser(username, attributes...)}} method to {{KnoxLDAPService}} / 
{{KnoxLDAPServerManager}}, next to {{lookupUserGroups}}. It returns the 
requested attributes and the user's groups. The search runs through the 
embedded server's admin session, so it uses the full interceptor chain: the 
proxy backend, attribute mapping and the roles lookup interceptor. 
{{lookupUserGroups}} is reimplemented on top of it.
* Escape the username in the {{(uid=...)}} search filter. It is currently 
concatenated unescaped, so a username such as {{*}} matches some other user. 
The fix also covers the existing {{lookupUserGroups}} callers (the Hadoop group 
provider and the delegation policy).
* Add {{KnoxLdapServiceUserParamsProvider}}. It maps cn/sn/givenName/mail to 
name/family_name/given_name/email, plus sub, email_verified and roles. Both 
providers share the claim mapping, so their output can't drift apart.
* Add the topology parameter {{user.params.provider.ldap.use.ldap.service}} 
(default {{false}}). When it is {{true}} and {{gateway.ldap.enabled}} is on, 
the new provider is used. It takes precedence over 
{{user.params.provider.ldap.url}}, and no URL, bind user or password alias is 
needed. If the embedded LDAP is disabled, a warning is logged and the existing 
behavior applies ({{url}} gives the JNDI provider; otherwise no user params). 
{{knoxidf.token.user.params.enabled}} still applies.
* Roles semantics: the new provider returns every group the LDAP service 
resolves (the same set {{HadoopGroupProvider}} sees). The JNDI provider keeps 
only the groups directly under {{groupSearchBase}}. With the roles lookup 
interceptor enabled, both return the same roles.
* Document the new parameter in {{knox-site/docs/knoxidf/configuration.md}}.

*Testing*
* Unit tests for {{lookupUser}} (attributes, groups, user not found, filter 
escaping), for the new provider, and for the provider factory's selection and 
fallback logic.
* E2E:
** A new {{knoxidf-token-ldap-service}} topology, which is {{knoxidf-token}} 
with only the new flag in place of the LDAP connection settings.
** A new {{test_user_params_claims}} test checks the profile and email claims 
in both the access token and /userinfo.
** The KnoxIDF suite is re-run through the new provider for guest and sam, with 
a parity check against the JNDI provider.
** REST roles lookup variants are added.
** The KnoxIDF E2E tests now revoke the tokens and auth codes they obtain, so 
they no longer use up the gateway-wide {{knox.token.limit.per.user}} that other 
suites share.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to