🐞 Keycloak: unexpected locale field when adding languages to realm #2660
🐞 Keycloak: unexpected locale field when adding languages to realm #2660Copilot wants to merge 4 commits into
Conversation
Agent-Logs-Url: https://github.com/sequentech/step/sessions/db61abf7-a447-4d11-9473-d575c09724c7 Co-authored-by: edulix <81968+edulix@users.noreply.github.com>
|
All contributors have signed the CLA. ✅ |
edulix
left a comment
There was a problem hiding this comment.
apply required changes in this same branch
| <#assign disabledElements = []> | ||
|
|
||
| <#list profile.attributes as attribute> | ||
| <#if attribute.name == "locale"> |
There was a problem hiding this comment.
I don't like this. Can't this be filtered in java properly instead?
There was a problem hiding this comment.
Addressed in 28d4b36: the locale field is now supplied from Java via HIDDEN_PROFILE_ATTRIBUTES, and the template only applies the generic Java-provided hidden attribute list instead of hardcoding locale.
| <dependency> | ||
| <groupId>org.junit.jupiter</groupId> | ||
| <artifactId>junit-jupiter</artifactId> | ||
| <version>5.11.4</version> |
There was a problem hiding this comment.
please ensure this is the latest version
There was a problem hiding this comment.
Addressed in 28d4b36: updated JUnit Jupiter to 6.0.3, the latest stable release listed in Maven metadata; 6.1.0-RC1 is a release candidate.
Agent-Logs-Url: https://github.com/sequentech/step/sessions/dfc939c6-7138-4f01-88f5-84ee0d7c85af Co-authored-by: edulix <81968+edulix@users.noreply.github.com>
Applied the required changes in this same branch in 28d4b36. |
There was a problem hiding this comment.
Pull request overview
Fixes deferred-registration failures when Keycloak realm internationalization injects a built-in locale user-profile attribute by (a) hiding locale from the rendered profile attributes and (b) preventing locale from surfacing as a required-field validation blocker during deferred registration.
Changes:
- Add
localeto a Java-providedhiddenProfileAttributesset and pass it to the theme solocaleisn’t rendered as a user-editable/required field. - Strip
UserModel.LOCALEfrom normalized form data and filter out the specific “required locale” validation error. - Add focused JUnit tests covering locale removal, hidden attribute configuration, and locale-required error filtering.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/keycloak-extensions/voter-enrollment/src/main/java/sequent/keycloak/voter_enrollment/DeferredRegistrationUserCreation.java | Removes locale from normalized form params, ignores required-locale validation error, and exposes hiddenProfileAttributes to the form/theme. |
| packages/keycloak-extensions/voter-enrollment/src/test/java/sequent/keycloak/voter_enrollment/DeferredRegistrationUserCreationTest.java | Adds regression tests for locale stripping, hidden attribute configuration, and required-locale error matching. |
| packages/keycloak-extensions/voter-enrollment/pom.xml | Adds a JUnit dependency for the new tests (currently with an invalid/nonexistent version). |
| packages/keycloak-extensions/sequent-theme/src/main/resources/theme/sequent.admin-portal/login/user-profile-commons.ftl | Skips rendering profile attributes present in hiddenProfileAttributes (e.g., locale). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Parent issue: https://github.com/sequentech/meta/issues/11716
Keycloak adds a built-in
localeuser-profile attribute when realm internationalization is enabled. In deferred registration, this surfaced as an unexpected required field.Form rendering
hiddenProfileAttributeslist containinglocale.profile.attributes.Deferred registration validation
UserModel.LOCALEfrom normalized form data before creating theUserProfile.locale.Regression coverage