feat(cli): add device code auth flow for remote/headless servers#11934
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
feat(cli): add device code auth flow for remote/headless servers#11934roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
Adds a --device-code flag to `roo auth login` that implements a device code authentication flow similar to GitHub CLI. This allows users on remote or headless servers to authenticate by: 1. Running `roo auth login --device-code` 2. Opening a verification URL on any device with a browser 3. Entering the displayed user code 4. CLI polls for completion and saves the token The server-side endpoints (POST /api/cli/device-code and POST /api/cli/device-code/poll) need to be implemented separately. Closes #11925
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.
Related GitHub Issue
Closes: #11925
Description
This PR attempts to address Issue #11925 by adding a device code authentication flow to the CLI, similar to how GitHub CLI handles authentication on remote/headless servers.
The problem: The current
roo auth logincommand starts a local HTTP server on127.0.0.1and expects a browser redirect back to localhost. This does not work on remote or cloud servers where the user's browser is on a different machine.The solution: A new
--device-codeflag onroo auth loginthat implements a device code flow:roo auth login --device-codeAUTH_BASE_URL/api/cli/device-codeAUTH_BASE_URL/api/cli/device-code/polluntil auth completesKey implementation details:
useDeviceCodeoption toLoginOptionsinterfacelogin()to route between browser callback (default) and device code flowsdeviceCodeLogin(),pollForToken(),httpPost()--device-codeCLI flag via CommanderNote: This PR implements the client-side (CLI) portion. The server-side endpoints (
POST /api/cli/device-codeandPOST /api/cli/device-code/poll) need to be implemented on the auth server. The expected API contract is documented in the type interfaces.Feedback and guidance are welcome.
Test Procedure
apps/cli/src/commands/auth/__tests__/login.test.tscd apps/cli && npx vitest run src/commands/auth/__tests__/login.test.tsPre-Submission Checklist
Documentation Updates
--device-codeflag for remote server usage.Additional Notes
The server-side device code endpoints follow the standard OAuth 2.0 Device Authorization Grant pattern (RFC 8628). The expected response shapes are:
POST /api/cli/device-code returns:
{ "device_code": "...", "user_code": "ABCD-1234", "verification_uri": "https://...", "expires_in": 900, "interval": 5 }POST /api/cli/device-code/poll with
{ "device_code": "..." }returns:{ "status": "pending" | "complete" | "expired", "token": "..." }Interactively review PR in Roo Code Cloud