8000 Persist default values of read-only UP attributes on user creation by ssilvert · Pull Request #54401 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Persist default values of read-only UP attributes on user creation - #54401

Merged
pedroigor merged 1 commit into
keycloak:mainfrom
ssilvert:issue-50505-default-attrib-not-saved
Oct 28, 2026
Merged

pedroigor merged 1 commit into
keycloak:mainfrom
ssilvert:issue-50505-default-attrib-not-saved

Conversation

@ssilvert
Copy link
Copy Markdown
Contributor

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

…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
Copilot AI balanced review requested due to automatic review settings October 28, 2026 09:26
@ssilvert
ssilvert requested a review from a team as a code owner October 28, 2026 09:26
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 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
pedroigor merged commit ef10c1d into keycloak:main Oct 28, 2026
98 checks passed
@Cyclone5
Cyclone5 commented Oct 28, 2026 •
Copy link
Copy Markdown

Thanks! @ssilvert & @pedroigor

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.

User Profile attribute default value not persisted on user creation, missing in jwt user attribute

4 participants

0