KNOX-3423: Switch to JSON error messages in Knox token validation paths - #1354
Conversation
Test Results 4 files 4 suites 10s ⏱️ Results for commit dc91bf3. ♻️ This comment has been updated with latest results. |
hsheinblatt
left a comment
There was a problem hiding this comment.
Thanks Tamás. LGTM. I think a couple of the error types might be incorrect, and there may be a missing test -- see comments -- but looks to make it spec compliant.
I made some changes to address your comments.
As per RFC 8693 §2.2.2: If the request itself is not valid or if either the subject_token or actor_token are invalid for any reason, or are unacceptable based on policy, the authorization server MUST construct an error response, as specified in Section 5.2 of [RFC6749]. The value of the error parameter MUST be the invalid_request error code. Due to the above |
…n error body
The token-issuance error for a rejected resource/audience echoed the
caller-supplied resource value back inside a hand-concatenated JSON body,
so a value containing a double quote (or other JSON metacharacter) could
break out of the JSON string and corrupt the response.
Render the {"error": ..., "code": ...} body through JsonUtils instead of
string concatenation, which escapes the embedded value the same way the
KNOX-3423 (apache#1354) filter-layer error path does. The {error, code} shape
and ErrorCode contract used by the token lifecycle responses are kept.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
KNOX-3423 - Switch to JSON error messages in Knox token validation paths
What changes were proposed in this pull request?
RFC 8693 §2.2.2 / RFC 6749 §5.2 require OAuth token-exchange errors to be a JSON
body (
{"error", "error_description"}) withContent-Type: application/json.JWTFederationFilterpreviously emitted plain-text/HTML (sendError) for everypath, breaking standards-compliant clients.
body with
Cache-Control: no-store/Pragma: no-cache. HTTP status codes areunchanged (400 for param/nbf/audience, 401 for signature/expiry/parse).
TOKEN_EXCHANGE_REQUEST_ATTR: both the direct param/parse errors inTokenExchangeHandlerand the shared JWT-validation errors emitted byAbstractJWTFilter(expired / bad-signature / wrong-audience / …). The latter isthe gap a handler-only fix would miss.
plain text.
How was this patch tested?
Unit tests, local tests
Integration Tests
N/A
UI changes
N/A