Repository navigation
Conversation
Closes keycloak#52215 Signed-off-by: Pramod Ubbala <16706816+upramod@users.noreply.github.com>
f40d23e to
7ab41dc
Compare
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused validator change resolves the reported behavior while existing tests continue to cover real username mutations.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes LDAP-backed profile updates when an unchanged read-only username differs only by case.
Changes:
- Compares read-only usernames case-insensitively.
- Adds regression coverage for LDAP-style preserved casing.
| File | Description |
|---|---|
services/src/main/java/org/keycloak/userprofile/validator/UsernameMutationValidator.java |
Allows case-only username differences. |
tests/base/src/test/java/org/keycloak/tests/user/profile/UserProfileTest.java |
Tests the LDAP casing scenario. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@pedroigor This implements the server-side case-insensitive username validation you suggested in #52215. The change is limited to UsernameMutationValidator and a regression test covering LDAP-style username casing. Actual username changes remain rejected. All five fork validation workflows passed, and the commit is signed off. Upstream CI still requires maintainer authorization. Could you review this approach and let me know whether any changes are needed before acceptance? |
|
@keycloak/core-iam Could someone please review this when available? The change is narrowly scoped to the LDAP-backed read-only username case: comparisons are now case-insensitive while genuine username changes remain rejected. The regression test covers the preserved-case LDAP scenario, and the automated review found no issues. Please let me know if any additional changes or validation are needed. |
|
|
||
| String valueLowercased = value.toLowerCase(); | ||
| if (!realm.isEditUsernameAllowed() && user != null && !valueLowercased.equals(user.getFirstAttribute(UserModel.USERNAME))) { | ||
| if (!realm.isEditUsernameAllowed() && user != null && !value.equalsIgnoreCase(user.getFirstAttribute(UserModel.USERNAME))) { |
Signed-off-by: Pramod Ubbala <16706816+upramod@users.noreply.github.com>
|
The latest automated review reports no blocking findings for the read-only LDAP username validation fix. Could a maintainer review the implementation and regression coverage and advise whether any additional changes are required? I can address specific feedback. |


Closes #52215
Problem
When username editing is disabled,
UsernameMutationValidatorlowercases the submitted username but compares it with the stored username without normalizing the stored value. LDAP-backed users can preserve username casing, so an unchanged username such asLDAP-Case-Usersubmitted asldap-case-useris treated as a mutation and blocks unrelated profile updates.Change
Use a case-insensitive comparison when deciding whether the read-only username changed. Real username changes are still rejected.
Test
Added a regression in
UserProfileTestthat simulates an LDAP-style stored username with preserved case and validates the same username with a case-only difference while username editing is disabled.Fork validation: upramod#1