8000 Allow local attribute updates for read-only LDAP users by Oluwatobi-Mustapha · Pull Request #54840 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Allow local attribute updates for read-only LDAP users - #54840

Open
Oluwatobi-Mustapha wants to merge 1 commit into
keycloak:mainfrom
Oluwatobi-Mustapha:ldap-local-attributes
Open

Oluwatobi-Mustapha wants to merge 1 commit into
keycloak:mainfrom
Oluwatobi-Mustapha:ldap-local-attributes

Conversation

@Oluwatobi-Mustapha
@Oluwatobi-Mustapha Oluwatobi-Mustapha commented Nov 7, 2026 •
Copy link
Copy Markdown
Contributor

Keep edit permissions aligned with User Profile policy: imported users can retain Keycloak-only profile data while LDAP remains authoritative for mapped attributes. Import-disabled users keep their existing restrictions.

Closes #54529

@Oluwatobi-Mustapha
Oluwatobi-Mustapha marked this pull request as ready for review November 7, 2026 20:41
@Oluwatobi-Mustapha
Oluwatobi-Mustapha requested review from a team as code owners November 7, 2026 20:41
Copilot AI balanced review requested due to automatic review settings November 7, 2026 20:41
Copilot AI 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.

🟡 Changes recommended

Hardcoded attribute filters can hide unimported LDAP users, and email updates for imported users without an email mapper can pass validation but fail on a protected username when “Email as username” is enabled.

2 open issues
What changed in this PR

Allows imported read-only LDAP users to update Keycloak-only profile data while preserving LDAP ownership and User Profile permissions. Users with imports disabled retain their existing restrictions.

Changes:

  • Limits read-only protection to provider-owned and mapper-declared attributes.
  • Adds coverage for local updates, profile permissions, and mapped-attribute protection.
  • Documents the revised read-only behavior and mapper ownership contract.
File Description
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​org/​keycloak/​testsuite/​federation/​ldap/​LDAPReadOnlyTest.java Adds local-update and LDAP-protection scenarios.
testsuite/​integration-arquillian/​tests/​base/​src/​test/​java/​ 8000 org/​keycloak/​testsuite/​federation/​ldap/​LDAPAccountRestApiTest.java Covers local profile updates through the Account API.
federation/​ldap/​src/​main/​java/​org/​keycloak/​storage/​ldap/​ReadonlyLDAPUserModelDelegate.java Applies attribute-specific write restrictions.
federation/​ldap/​src/​main/​java/​org/​keycloak/​storage/​ldap/​mappers/​LDAPStorageMapper.java Documents mapper attribute ownership requirements.
federation/​ldap/​src/​main/​java/​org/​keycloak/​storage/​ldap/​mappers/​HardcodedAttributeMapper.java Declares the hardcoded attribute as mapper-owned.
federation/​ldap/​src/​main/​java/​org/​keycloak/​storage/​ldap/​LDAPStorageProvider.java Aligns model restrictions and profile metadata with attribute ownership.
docs/​documentation/​server_admin/​topics/​user-federation/​ldap.adoc Explains local updates for imported read-only users.

Review effort: Balanced

@Oluwatobi-Mustapha
Oluwatobi-Mustapha force-pushed the ldap-local-attributes branch 2 times, most recently from 77d1c53 to 3dfbd83 Compare November 7, 2026 20:51
Copilot AI balanced review requested due to automatic review settings November 7, 2026 20:51
Copilot AI 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.

🟡 Changes recommended

Duplicate attribute metadata can break profile reads and updates, while forwarding hardcoded enabled filters to LDAP can incorrectly return no users.

3 open issues

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 7, 2026 21:31
Copilot AI 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.

🔵 Needs a closer look

Case-insensitive protection misses custom LDAP attribute aliases, allowing local writes that remain masked by LDAP reads; the delegate and User Profile metadata must protect these aliases consistently.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Protect case-insensitive aliases for all LDAP-mapped attributes

federation/​ldap/​src/​main/​java/​org/​keycloak/​storage/​ldap/​LDAPStorageProvider.java:1288

Case-insensitive protection is limited to three properties, but UserAttributeLDAPStorageMapper also matches custom names case-insensitively. With a postal_code mapper and “Always Read Value From LDAP” enabled, writes to POSTAL_CODE now succeed as local writes while getAttributeStream("POSTAL_CODE") still returns the LDAP value; protect these aliases consistently in both the delegate and User Profile metadata.

3 resolved since last review

Review effort: Balanced

@martin-kanis martin-kanis left a comment
< 8000 summary data-dd-action-name="comment.open_menu" data-view-component="true" class="timeline-comment-action Link--secondary Button--link Button--medium Button"> Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@Oluwatobi-Mustapha Thank you for the PR. I have some suggestions:

  • Could you put the regression tests added by this PR in the new test framework under tests/base? The arquillian testsuite is now deprecated. The existing tests/base infrastructure should be sufficient.
  • Could you add a short upgrade note for custom LDAP mapper authors? Before this change, the read-only delegate blocked writes to custom attributes even if their mapper didn’t declare them. With this PR, an undeclared attribute can be treated as locally writable for imported users. AbstractLDAPStorageMapper#getUserAttributes() returns an empty set by default. The Javadoc explains the contract, and an upgrade note would prompt existing mapper authors to check that they declare every attribute they manage.

Copilot AI balanced review requested due to automatic review settings November 25, 2026 17:19
Copilot AI 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.

🟢 Approval recommended

No active review issues were identified for the LDAP attribute-ownership changes.

No open issues 🎉

Review effort: Balanced

Closes keycloak#54529

Signed-off-by: Oluwatobi Mustapha <oluwatobimustapha539@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 17:49
Copilot AI 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.

🟢 Approval recommended

No active review issues block the change enabling policy-controlled edits to Keycloak-only attributes for imported read-only LDAP users.

No open issues 🎉

Review effort: Balanced

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow changing local attributes when LDAP edit mode is READ_ONLY

3 participants

0