Skip to content

AuthZEN: accept action.properties and ignore unknown request fields - #55264

Open
Inf1mum wants to merge 1 commit into
keycloak:mainfrom
Inf1mum:keycloak-54542-authzen-lenient-parsing
Open

Inf1mum wants to merge 1 commit into
keycloak:mainfrom
Inf1mum:keycloak-54542-authzen-lenient-parsing

Conversation

@Inf1mum

@Inf1mum Inf1mum commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #54542

What

AuthZEN evaluation requests that carry action.properties, unknown keys inside options, or any unknown field (top-level or inside subject, resource, action, or an evaluations item) are currently rejected with 400 Bad Request before authentication. Two causes, both fixed here:

  1. AuthZen.Action was declared as record Action(String name), so the OPTIONAL properties key defined by AuthZEN 1.0 Section 5.3 failed request parsing with Unrecognized field "properties".
  2. The AuthZEN request records did not opt out of the server-wide strict Jackson behaviour, so any unknown field failed parsing and KcUnrecognizedPropertyExceptionHandler turned 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

  • Added the optional properties map to AuthZen.Action (a convenience Action(String name) constructor keeps existing call sites working).
  • Annotated the AuthZEN request records (Subject, Resource, Action, EvaluationRequest, EvaluationItem, Options, EvaluationsRequest) with @JsonIgnoreProperties(ignoreUnknown = true).

Scope note (regarding the open question in the issue): action.properties is 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.properties accepted; unknown fields ignored inside action, subject, resource, and at the top level (all previously 400).
  • AuthZenEvaluationsTest: unknown keys inside options next to evaluations_semantic; action.properties plus an unknown field inside an evaluations item.

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.

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>
@Inf1mum
Inf1mum requested a review from a team as a code owner November 17, 2026 11:09
Copilot AI balanced review requested due to automatic review settings November 17, 2026 11:09

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.

🟡 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.properties without 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) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AuthZEN: requests with action.properties or unknown fields are rejected with 400

2 participants