{{ message }}
Repository navigation
fix(auth): align /token and /revoke error codes with RFC 6749 and RFC 7009 (#3723) - #3733
Closed
nikolas-sapa wants to merge 1 commit into
Closed
nikolas-sapa wants to merge 1 commit into
nikolas-sapa wants to merge 1 commit into
Conversation
Contributor
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.

Summary
Closes #3723.
This PR aligns the error responses returned by the built-in authorization server on
/tokenand/revokewith RFC 6749 §5.2 and RFC 7009 §2.2.1:/tokenwith grant supported by server but unauthorized for client: returnserror="unauthorized_client"instead ofunsupported_grant_type(RFC 6749 §5.2: "The authenticated client is not authorized to use this authorization grant type")./tokenwith grant unsupported by server (e.g.client_credentials,password, unknown): returnserror="unsupported_grant_type"instead of failing Pydantic union validation withinvalid_request(RFC 6749 §5.2: "The authorization grant type is not supported by the authorization server")./revokewith client authentication failure: returnserror="invalid_client"instead ofunauthorized_client(RFC 7009 §2.2.1 / RFC 6749 §5.2). Addedinvalid_clientandunsupported_token_typetoRevocationErrorResponse.WWW-Authenticateheader on HTTP 401: when a client attempts to authenticate viaAuthorization: Basic ...on/tokenor/revokeand authentication fails, the response now includesWWW-Authenticate: Basic realm="OAuth"per RFC 6749 §5.2.Test Plan
tests/server/auth/test_error_handling.pycovering all four cases (verified failing RED on base, passing GREEN on fix).tests/server/auth/test_identity_assertion.pytesting unauthorized client registration.tests/server/authandtests/interaction/auth: 176 passed.ruff checkandruff format --check: clean.pyright: 0 errors, 0 warnings.