Repository navigation
Conversation
AuthZEN 1.0 Section 5.3 defines an optional properties key on the action object, and Section 10.1.1 requires receivers to ignore unknown fields in request bodies. The AuthZEN request records inherited the server-wide strict Jackson behaviour, so requests carrying action.properties, unknown keys inside options, or any unknown field were rejected with 400 before authentication. - add the optional properties map to AuthZen.Action - annotate the AuthZEN request records with @JsonIgnoreProperties(ignoreUnknown = true) - per the open question in the issue, action.properties is accepted but not merged into the evaluation context in this first step - cover action.properties, unknown fields (top-level, subject, resource, action, evaluations item) and unknown option keys with integration tests Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The action name is not required, so invalid requests can return a 200 denial instead of a 400 error.
1 open issue
What changed in this PR
Improves AuthZEN 1.0 request compatibility in Keycloak’s authorization services, addressing #54542.
Changes:
- Accepts optional
action.propertieswithout adding them to the policy evaluation context. - Ignores unknown fields across single and batch evaluation request records.
- Adds regression tests for action properties and unknown request fields.
| File | Description |
|---|---|
authzen/tests/base/src/test/java/org/keycloak/tests/authzen/AuthZenEvaluationTest.java |
Tests action properties and unknown fields in single evaluations. |
authzen/tests/base/src/test/java/org/keycloak/tests/authzen/AuthZenEvaluationsTest.java |
Tests unknown option keys and action properties within batch items. |
authzen/services/src/main/java/org/keycloak/authorization/authzen/AuthZen.java |
Adds action properties, preserves the convenience constructor, and enables unknown-field tolerance. |
Review effort: Balanced
| @JsonIgnoreProperties(ignoreUnknown = true) | ||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public record Action(String name) {} | ||
| public record Action(String name, Map<String, Object> properties) { |
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.
Fixes #54542
What
AuthZEN evaluation requests that carry
action.properties, unknown keys insideoptions, or any unknown field (top-level or insidesubject,resource,action, or anevaluationsitem) are currently rejected with400 Bad Requestbefore authentication. Two causes, both fixed here:AuthZen.Actionwas declared asrecord Action(String name), so the OPTIONALpropertieskey defined by AuthZEN 1.0 Section 5.3 failed request parsing withUnrecognized field "properties".KcUnrecognizedPropertyExceptionHandlerturned it into a 400. AuthZEN 1.0 Section 10.1.1 requires: "To ensure forward compatibility, receivers MUST ignore unknown fields present in request or response bodies."How
propertiesmap toAuthZen.Action(a convenienceAction(String name)constructor keeps existing call sites working).Subject,Resource,Action,EvaluationRequest,EvaluationItem,Options,EvaluationsRequest) with@JsonIgnoreProperties(ignoreUnknown = true).Scope note (regarding the open question in the issue):
action.propertiesis accepted but, in this first step, not merged into the evaluation context, as proposed in the issue description. If maintainers prefer it to feed the claim/context map, that can be a follow-up together with the related property-collision questions discussed in #53328 and #54848.Tests
AuthZenEvaluationTest:action.propertiesaccepted; unknown fields ignored insideaction,subject,resource, and at the top level (all previously 400).AuthZenEvaluationsTest: unknown keys insideoptionsnext toevaluations_semantic;action.propertiesplus an unknown field inside anevaluationsitem.The pre-existing 400 behaviour for missing/invalid required fields and invalid JSON is unchanged and remains covered by the tests already in these classes.