fix(oauth): Reject device code requests from unauthorised clients #2110

Merged
nex merged 2 commits from mmaudet/continuwuity:fix/oauth-device-grant-type into main 2026-08-07 08:52:21 +00:00

2 commits

Author SHA1 Message Date
b23059734e
fix(oauth): Use unauthorized_client for unregistered grant types
All checks were successful
Checks / Changelog / Check changelog is added (pull_request_target) Successful in 7s
Documentation / Build and Deploy Documentation (pull_request) Has been skipped
Checks / Prek / Check changed files (pull_request) Successful in 6s
Checks / Prek / Pre-commit & Formatting (pull_request) Successful in 1m15s
Checks / Prek / Clippy and Cargo Tests (pull_request) Successful in 8m30s
The token endpoint already refused grant types the client had not
registered, but reported it as `invalid_grant`. RFC 6749 section 5.2
reserves `invalid_grant` for an authorization grant which is "invalid,
expired, revoked, does not match the redirection URI used in the
authorization request, or was issued to another client", and defines
`unauthorized_client` for a client which "is not authorized to use this
authorization grant type".

Report the condition with the error code the specification assigns to it,
matching the device authorization endpoint.
2026-08-06 20:24:18 +02:00
d9afc79a0b
fix(oauth): Reject device code requests from unauthorised clients
The device authorization endpoint issued a device code to any registered
client, without checking that the client had registered the
`urn:ietf:params:oauth:grant-type:device_code` grant type. Such a client
could therefore start a device authorization flow and have the server
show an approval prompt to a user, even though the subsequent token
request was always going to be refused.

RFC 8628 section 3.2 states that, in the event of an error such as an
invalidly configured client, the device authorization endpoint responds
in the same way as the token endpoint specified in RFC 6749 section 5.2,
which defines `unauthorized_client` as "the authenticated client is not
authorized to use this authorization grant type".

Apply the same grant type check the token endpoint already performs, and
add the `unauthorized_client` error code it requires.
2026-08-06 20:24:09 +02:00