Skip to content

feat(cli): support OIDC device authorization grant for headless login - #2795

Merged
sjenning merged 4 commits into
NVIDIA:mainfrom
jhjaggars:feat/2793-oidc-device-code-flow/jhjaggars
Aug 19, 2026
Merged

feat(cli): support OIDC device authorization grant for headless login#2795
sjenning merged 4 commits into
NVIDIA:mainfrom
jhjaggars:feat/2793-oidc-device-code-flow/jhjaggars

Conversation

@jhjaggars

@jhjaggars jhjaggars commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Add OAuth 2.0 Device Authorization Grant (RFC 8628) support so operators can authenticate interactively against OIDC-secured gateways from headless environments without a local browser or confidential client secret.

Related Issue

Closes #2793

Changes

  • Discover the optional OIDC device_authorization_endpoint
  • Use device authorization when OPENSHELL_NO_BROWSER=1 and no client secret is configured
  • Protect device authorization with S256 PKCE for providers such as Keycloak that enforce PKCE on public clients
  • Display the verification URL and user code while polling for approval
  • Handle authorization_pending, slow_down, access_denied, and expired_token responses
  • Validate successful token responses before storing credentials
  • Store device-flow tokens through the existing OIDC token bundle path
  • Add unit coverage for discovery, PKCE form parameters, and device authorization response parsing
  • Document the explicit headless device-code mode

Testing

  • mise run pre-commit passes
  • cargo test -p openshell-cli oidc passes (27 tests)
  • Manual end-to-end test against Keycloak with Device Authorization Grant and enforced S256 PKCE
  • Branch CLI completed headless login, stored the token bundle, and authenticated whoami against an OIDC-secured OpenShell gateway
  • Fresh ARM64 gateway and supervisor images built and deployed to a mixed-architecture OpenShift cluster with ARM64 scheduling constraints

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

@copy-pr-bot

copy-pr-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@jhjaggars
jhjaggars marked this pull request as ready for review August 18, 2026 23:09
Closes NVIDIA#2793

Add OAuth 2.0 Device Authorization Grant (RFC 8628) support to the OpenShell CLI's OIDC login flow. When running in a headless environment (OPENSHELL_NO_BROWSER=1) without a client secret configured, the CLI now uses the device code flow instead of the browser-based PKCE flow.

The device code flow:
- Requests a device code and user code from the IdP's device authorization endpoint
- Displays a verification URL and user code to the user
- Polls the token endpoint until the user completes authorization or the code expires
- Supports slow_down responses per RFC 8628 by increasing the polling interval

This implementation:
- Extends OidcDiscovery to optionally capture device_authorization_endpoint
- Adds oidc_device_code_flow function with proper error handling for all RFC 8628 error codes
- Updates gateway add and gateway login to dispatch to device flow when browser is suppressed
- Adds comprehensive unit tests for device flow structs and response parsing
- Updates gateway authentication documentation to describe the device code fallback

Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
Signed-off-by: Jesse Jaggars <jjaggars@redhat.com>
@jhjaggars
jhjaggars force-pushed the feat/2793-oidc-device-code-flow/jhjaggars branch from f0608ac to 7b93ed1 Compare August 19, 2026 16:50
@sjenning

Copy link
Copy Markdown
Collaborator

/ok to test 7b93ed1

@sjenning sjenning left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this and it works

$ openshell gateway login

  To authenticate, visit:
    https://keycloak..../realms/openshell/device?user_code=SGNA-TVCH

  Waiting for authorization...
✓ Authenticated to gateway 'openshell-keycloak' as admin@test

@sjenning
sjenning added this pull request to the merge queue Aug 19, 2026
Merged via the queue into NVIDIA:main with commit 2eb0880 Aug 19, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: support OIDC device authorization grant for headless CLI login

2 participants