Skip to content

KNOX-3589: Rename remote LDAP attributes to proxy-facing names - #1528

Merged
smolnar82 merged 2 commits into
apache:masterfrom
handavid:KNOX-3589-map-remote-attributes
Nov 19, 2026
Merged

smolnar82 merged 2 commits into
apache:masterfrom
handavid:KNOX-3589-map-remote-attributes

Conversation

@handavid

@handavid handavid commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

KNOX-3589 - Rename remote LDAP attributes to proxy-facing names

What changes were proposed in this pull request?

The LDAP proxy surfaces remote attributes under their own names. Add a per-backend attributeMappings list of remoteName:proxyName pairs so a remote attribute can be exposed under a different, standard name on the proxy entry (e.g. Active Directory's whenChanged as the RFC-standard modifyTimestamp), without the client needing to know an AD server is behind the proxy.

Mappings that include a sensitive attribute name are rejected so that mapping cannot be used to surface sensitive values.

The rename is bidirectional and applied in all three places so the proxy name works end to end:

  • on returned entries, the remote attribute is copied into the proxy entry under the proxy name and the remote name is dropped;
  • in the client's requested-attribute list, the proxy name is forwarded to the remote server as the remote name (the only name it knows); Attribute replacement is performed before the LdapProxyBackend modifies the attribute list so that the mapping doesn't impact the objectClass, memberOf, or userIdentifierAttribute that are automatically added to the search.
  • in search filters, a condition on the proxy name is rewritten to the remote name before the search is sent.

Values are copied verbatim, so only syntax-compatible attributes should be mapped (whenChanged and modifyTimestamp are both GeneralizedTime). The target name must be resolvable in the schema; modifyTimestamp is a standard operational attribute Knox already knows. Lookups are case-insensitive and malformed pairs are skipped rather than failing the backend. Credential-bearing attributes are still stripped before any rename, so a mapping cannot surface secrets under a different name.

How was this patch tested?

Added unit tests.

Ran manual tests against active directory by adding a mapping to the gateway-site.xml

    <property>
        <name>gateway.ldap.interceptor.adexample.attributeMappings</name>
        <value>whenChanged:modifyTimestamp</value>
    </property>

then ran searches using modifyTimestamp and see that the search works to narrow the result set and that modifyTimestamp is included in the returned entries. Since modifyTimestamp is an operational attribute in the proxy schema, it needs to be requested explicitly or throug + for all operational attributes.

ldapsearch -v -x -H ldap://localhost:3890  -D 'uid=bind2,ou=people,dc=proxy,dc=com' -w bind-password  -E pr=250/noprompt -b 'ou=people,DC=proxy,DC=com' -s sub '(&(objectClass=inetOrgPerson)(modifyTimestamp>=20261115074418.0Z))' '*' '+'
...
# configurator1, people, proxy.com
dn: CN=configurator1,ou=people,dc=proxy,dc=com
sAMAccountName: configurator1
objectGUID:: 5o6gb6zrl0CzZhYUVaj8Pg==
name: configurator1
memberOf: CN=configurators,ou=groups,dc=proxy,dc=com
givenName: configurator1
modifyTimestamp: 20261118163452.0Z
userAccountControl: 66048
displayName: configurator1
cn: configurator1
objectclass: top
objectclass: organizationalPerson
objectclass: user
objectclass: inetOrgPerson
distinguishedName: CN=configurator1,ou=people,dc=proxy,dc=com
uid: configurator1

Integration Tests

No integration test were added because the test server has the same schema as the proxy server.

UI changes

No UI changes

The LDAP proxy surfaces remote attributes under their own names. Add a
per-backend attributeMappings list of remoteName:proxyName pairs so a
remote attribute can be exposed under a different, standard name on the
proxy entry (e.g. Active Directory's whenChanged as the RFC-standard
modifyTimestamp), without the client needing to know an AD server is
behind the proxy.

The rename is bidirectional and applied in all three places so the proxy
name works end to end:
  - on returned entries, the remote attribute is copied into the proxy
    entry under the proxy name and the remote name is dropped;
  - in the client's requested-attribute list, the proxy name is
    forwarded to the remote server as the remote name (the only name it
    knows);
  - in search filters, a condition on the proxy name is rewritten to the
    remote name before the search is sent.

Values are copied verbatim, so only syntax-compatible attributes should
be mapped (whenChanged and modifyTimestamp are both GeneralizedTime).
The target name must be resolvable in the schema; modifyTimestamp is a
standard operational attribute Knox already knows. Lookups are
case-insensitive and malformed pairs are skipped rather than failing the
backend. Credential-bearing attributes are still stripped before any
rename, so a mapping cannot surface secrets under a different name.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@smolnar82 smolnar82 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small possible NPE

…ons, log skips)

Follow-up fixes to the attributeMappings feature:

- Reject any mapping pair naming a credential-bearing attribute on either
  side. Renaming a sensitive attribute in would surface non-secret data
  under a credential name; renaming one out would let a filter on the
  proxy name be rewritten against the remote credential attribute (a
  guessing oracle). The strip of returned entries only covered the
  output path, not filters, so rejecting at config time closes both.

- Translate client-supplied attribute names to remote names before the
  proxy appends its own required remote attributes (objectClass,
  memberOf, the user identifier), so a mapping whose proxy name collides
  with one of them can no longer rewrite the attribute the proxy adds for
  its own use and break group resolution.

- Log a warning when a malformed attributeMappings entry is skipped
  (missing colon, empty side, or a stray second colon) instead of
  dropping it silently.

- Document that the modifyTimestamp rename is unconditional: it is
  applied to whatever the remote returns, so any whenChanged in a result
  is surfaced as modifyTimestamp regardless of whether the proxy name was
  requested by name. modifyTimestamp remains operational.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Test Results

  5 files    5 suites   1m 16s ⏱️
227 tests 226 ✅ 1 💤 0 ❌
271 runs  270 ✅ 1 💤 0 ❌

Results for commit 911fa70.

@smolnar82
smolnar82 merged commit ddf6284 into apache:master Nov 19, 2026
3 checks passed
@handavid
handavid deleted the KNOX-3589-map-remote-attributes branch November 19, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants