Repository navigation
Persist default values of read-only UP attributes on user creation - #54401
Merged
pedroigor merged 1 commit intoOct 28, 2026
Merged
Conversation
…reation When a user profile attribute has a default value but the user cannot edit it, the default was applied to the profile's attributes and then dropped, because only writable attributes are persisted. Users created through self-registration or first broker login ended up without the value, so protocol mappers found nothing even though the admin console showed the default. The default is now set from the attribute configuration after the user is created, both in DefaultUserProfile.create() and when first broker login creates the user directly. Values submitted for read-only attributes are still ignored. Fixes keycloak#50505 Signed-off-by: Stan Silvert <ssilvert@redhat.com> Assisted-by: Claude Opus 5.5
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the changes that persist configured defaults for read-only user-profile attributes during user creation.
No open issues 🎉
What changed in this PR
Addresses #50505 by persisting configured defaults for read-only user-profile attributes during user creation, making those values available to protocol mappers without an admin save.
Changes:
- Adds a shared helper that applies configured defaults when read-only attributes have no stored value.
- Calls the helper during profile-based creation and first broker login.
- Adds regression tests for stored defaults and ignored user-submitted read-only values.
| File | Description |
|---|---|
tests/base/src/test/java/org/keycloak/tests/user/profile/UserProfileTest.java |
Tests read-only default persistence during registration. |
tests/base/src/test/java/org/keycloak/tests/broker/IdpCreateUserIfUniqueAuthenticatorTest.java |
Verifies defaults are stored after first broker login. |
services/src/main/java/org/keycloak/authentication/authenticators/broker/IdpCreateUserIfUniqueAuthenticator.java |
Applies defaults to newly created broker users. |
server-spi-private/src/main/java/org/keycloak/userprofile/UserProfileUtil.java |
Adds the shared read-only default persistence helper. |
server-spi-private/src/main/java/org/keycloak/userprofile/DefaultUser
8000
Profile.java |
Applies defaults after profile-based user creation. |
Review effort: Balanced
pedroigor
approved these changes
Oct 28, 2026
|
Thanks! @ssilvert & @pedroigor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a user profile attribute has a default value but the user cannot edit it, the default was applied to the profile's attributes and then dropped, because only writable attributes are persisted. Users created through self-registration or first broker login ended up without the value, so protocol mappers found nothing even though the admin console showed the default.
The default is now set from the attribute configuration after the user is created, both in DefaultUserProfile.create() and when first broker login creates the user directly. Values submitted for read-only attributes are still ignored.
Fixes #50505
Assisted-by: Claude Opus 5.5