fix: redirect unauthorized_client errors per RFC 6749 Section 4.1.2.1#1816
fix: redirect unauthorized_client errors per RFC 6749 Section 4.1.2.1#1816
Conversation
- Move `validate :redirect_uri` before `validate :client_supports_grant_flow` in PreAuthorization so the redirect URI is verified before an unauthorized_client error can fire. This prevents redirecting to an unvalidated (potentially attacker-controlled) URI. - Remove `:unauthorized_client` from `NON_REDIRECTABLE_STATES` so that when the client is known and its redirect URI is valid, an unauthorized_client response is sent via redirect as required by the spec. - Update `status` to return `:bad_request` for `unauthorized_client` (`:unauthorized` is only appropriate for `invalid_client`, which is an authentication failure). - Update specs to reflect the corrected behaviour. Fixes: #1578 Agent-Logs-Url: https://github.com/doorkeeper-gem/doorkeeper/sessions/d020e8cb-f3fa-4721-9b38-457c154eb533 Co-authored-by: nbulaj <[email protected]>
|
Addresses #1578 |
|
@copilot tests are failing, analyze and fix them |
|
@copilot hey, check why tests are failing and fix them |
…ized_client The unauthorized_client error is now redirected per RFC 6749 §4.1.2.1. Update the controller specs to assert the new redirect behaviour: - Non-API mode: response is a 302 redirect with error params in the URI fragment - API mode: JSON response with status/redirect_uri, HTTP 400 Also add a CHANGELOG.md entry. Agent-Logs-Url: https://github.com/doorkeeper-gem/doorkeeper/sessions/ba408183-296e-467b-a623-be19597424ae Co-authored-by: nbulaj <[email protected]>
The 6 failures were in
A CHANGELOG.md entry was also added (fixing the Changelog verifier failure).
Done — see the reply above. Fixed in 009c5fa (test updates + CHANGELOG) and 80c3a89 (strengthened assertion). |
|
https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2.1 |
lib/doorkeeper/oauth/pre_authorization.rb— movevalidate :redirect_uribeforevalidate :client_supports_grant_flowlib/doorkeeper/oauth/error_response.rb— remove:unauthorized_clientfromNON_REDIRECTABLE_STATES; updatestatusspec/lib/oauth/pre_authorization_spec.rb— update validation-order testspec/lib/oauth/error_response_spec.rb— updateunauthorized_clientredirectability and status testsspec/controllers/authorizations_controller_spec.rb— update "when client can not use grant flow" tests for both non-API and API mode; strengthen redirect_uri assertion toinclude("error=unauthorized_client")CHANGELOG.md— add entry for the fix