gnodet opened a new pull request, #30664: URL: https://github.com/apache/camel/pull/30664
## Summary Implements RFC 9470 step-up authentication support in `camel-oauth` validation profiles. When a valid bearer token does not meet the step-up requirements, consumers (platform-http, servlet, MCP server, …) reply with a structured `401` challenge that tells the client exactly what it needs to re-authenticate for — instead of returning a generic `invalid_token` error. ## Feature Two new configuration properties on a validation profile: ```properties # Accept only tokens with acr=2 (Keycloak MFA level, NIST level 2, …) camel.oauth.users-mfa.base-uri = https://idp.example.com/realms/demo camel.oauth.users-mfa.expected-audience = conference-api camel.oauth.users-mfa.required-acr = 2 # Optionally: reject tokens whose auth_time is older than 5 minutes camel.oauth.users-mfa.max-auth-age-seconds = 300 ``` A token that passes all existing checks (signature, expiry, issuer, audience) but fails the step-up checks is rejected with: ``` HTTP/1.1 401 Unauthorized WWW-Authenticate: Bearer error="insufficient_user_authentication", error_description="Step-up authentication required", acr_values="2", max_age=300 ``` ## Changes | File | What changed | |------|-------------| | `OAuthTokenValidationResult.ErrorCode` | Add `INSUFFICIENT_USER_AUTHENTICATION` enum constant | | `OAuthTokenValidationConfig` | Add `requiredAcr` (Set<String>) and `maxAuthAgeSeconds` (int) fields with getters/setters and copy-constructor support | | `OAuthTokenValidationConfigResolver` | Bind `required-acr` (comma-separated) and `max-auth-age-seconds` properties | | `JwtTokenValidator` | Add `checkStepUpClaims()` — validates `acr` and `auth_time` JWT claims after all other checks pass; new overload with these extra parameters | | `DefaultOAuthTokenValidationFactory` | Pass new parameters to `JwtTokenValidator`; add `checkIntrospectionStepUpClaims()` for the introspection path | | `OAuthHttpSecuritySupport` | Map `INSUFFICIENT_USER_AUTHENTICATION` → `Validation.insufficientUserAuthentication()`, build RFC 9470 `WWW-Authenticate` header | ## Validation logic - **`requiredAcr`** (comma-separated set): the token `acr` claim must equal exactly one of the configured values. Missing `acr` → rejected. - **`maxAuthAgeSeconds`** (positive int, 0 = disabled): the token `auth_time` claim must be present and `now - auth_time ≤ maxAuthAgeSeconds`. Missing `auth_time` → rejected. - Both checks run only when configured; no existing behavior is affected by default. - ACR is checked before `auth_time`, so the error message identifies the first failing requirement. - Both JWT (JWKS) and opaque (RFC 7662 introspection) token paths are covered. ## Tests - `JwtTokenValidatorTest`: 9 new test cases covering ACR match/mismatch/absent, `auth_time` within/beyond/absent, no-op when both unconfigured, combined ACR+auth_time pass, and ACR-first ordering. - `OAuthHttpSecuritySupportTest`: 5 new test cases covering end-to-end exchange rejection with step-up challenge, `WWW-Authenticate` header with `acr_values`+`max_age`, ACR-only, max-age-only, and null config. ## Related Closes CAMEL-27123 --- _Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
