Repository navigation
Conversation
…cope The display order of a client scope is stored in the gui.order attribute and is read as an integer when scopes are sorted, but the Admin REST API stored any string. A value such as "abc" was then listed in the Admin Console while the settings form showed the field as empty. Return a 400 Bad Request when the value is not an integer. A blank value is still accepted because it means that the display order is not set. Closes keycloak#55731 Signed-off-by: Kalent Chia <kccrcodes@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The validation allows Unicode whitespace that the persistence layer does not treat as blank, causing non-integer attribute values to be stored.
1 open issue
What changed in this PR
Adds server-side validation for client-scope display order, addressing #55731 through the Admin REST API.
Changes:
- Rejects non-integer
gui.ordervalues on create and update. - Preserves acceptance of blank values and negative integers.
- Adds regression tests for rejection, unchanged stored values, and clearing display order.
| File | Description |
|---|---|
| tests/base/src/test/java/org/keycloak/tests/admin/client/ClientScopeTest.java | Adds display-order validation tests. |
| services/src/main/java/org/keycloak/services/resources/admin/ClientScopesResource.java | Validates display order during creation. |
| services/src/main/java/org/keycloak/services/resources/admin/ClientScopeResource.java | Implements shared validation and applies it during updates. |
Review effort: Balanced
| return; | ||
| } | ||
| String guiOrder = clientScope.getAttributes().get(ClientScopeModel.GUI_ORDER); | ||
| if (guiOrder == null || guiOrder.isBlank()) { |
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.

Closes #55731
The Admin REST API now returns 400 for a non-integer
gui.orderon client scope create and update, using the same integer ruleOrderedModelalready applies when sorting.Decisions and assumptions:
min=0, but the server never did; happy to change this.Tests: new cases in
tests/baseClientScopeTestfail before the change (expected 400 but was 201) and pass after;ClientScopeTest,ParameterizedClientScopeTest,ClientScopeProtocolMapperTestandClientScopeEvaluateTestpass (63 tests).This change was written with the help of Grok Build. I reviewed it and ran the tests locally.