feat: add Device Authorization Grant (RFC 8628)#344
Merged
Conversation
Implements the full device authorization flow for headless devices and CLI tools. Includes device_authorization endpoint, user verification UI, token polling with slow_down/authorization_pending/expired_token errors, and cleanup integration. Closes #264 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Black-box HTTP tests covering device_authorization endpoint, token polling, discovery, and error cases. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add RFC 8628 section references on all validation checks and return paths - Add "Device Code" option to admin UI grant type selectors - Regenerate swagger documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ints
Replace server-rendered device verification templates with a React page
in the account UI. This leverages the existing OIDC authentication flow
instead of reimplementing login/MFA/passkey handling in the device flow.
- Add /account/api/device/{verify,authorize,deny} API endpoints
- Add Device.tsx page with code input, confirmation, and result states
- Add /device redirect handler for convenience URLs
- Remove server-rendered device_verify/confirm/success/denied templates
- Update verification_uri to use path format (/account/device/{code})
- Add device flow test page to debug-ui
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The verification_uri already points directly to /account/device, so the /device redirect routes were dead code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Mark device codes as consumed after successful token exchange to prevent replay attacks (RFC 8628 §3.5) - Verify device_code was issued to the requesting client_id before exchanging tokens (RFC 8628 §3.4) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Each slow_down response now increases the device code's interval by 5 seconds in the database. Also adds Pragma: no-cache header to the device authorization response per RFC 6749 §5.1. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Phase 13 compliance table covering all MUST/SHOULD/MAY requirements, security considerations checklist, discovery cross-check, and full test inventory. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
POST /oauth2/device_authorizationendpoint issuing device_code + user_code/oauth2/device(enter code, approve/deny)urn:ietf:params:oauth:grant-type:device_codepolling withauthorization_pending,slow_down,expired_token,access_deniederrorsdevice_codestabledevice_code_expiration(default 10m),device_code_polling_interval(default 5s)device_authorization_endpointand grant typeurn:ietf:params:oauth:grant-type:device_codegrant typeCloses #264
Test plan
pkg/devicecode/)go test -p 1 ./...)golangci-lint run ./...)🤖 Generated with Claude Code