Repository navigation
iDeploy: browser sign-in for the CLI (device flow) - #386
Merged
Merged
Conversation
- POST /api/v1/cli/auth/start (public): a secret device code for the CLI, a short code to show (no look-alike characters) and the page to open. - GET/POST /api/v1/cli/auth/requests/:code (session): the approval page reads the request and approves or refuses it; approving issues a one-year personal access token named after the machine. - POST /api/v1/cli/auth/poll (public): the token, handed over once. - Requests live 10 minutes in Redis. Mounted before the routers that authenticate all of /api/v1. - Web: /cli/authorize page; the page a signed-out visitor asked for is opened again after the console login (it used to land on the root).
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.
Why
First piece of the
idemCLI (repoIdem-AI/cli):idem loginopens the browser and shows a code; the developer approves on iDeploy, without copying a token. This is the device flow used by the Railway, Vercel and GitHub CLIs.API
POST /api/v1/cli/auth/start{ host }deviceCode(secret, 64 hex),userCode(ABCD-EFGH, no look-alike characters),verificationUrl,expiresIn600,interval3GET /api/v1/cli/auth/requests/:codePOST /api/v1/cli/auth/requests/:code{ approve }POST /api/v1/cli/auth/poll{ device_code }pending/approved+ token (handed over once, then deleted) /denied/expired/api/v1that authenticate everything (like the webhooks). Otherwisestartandpollwould answer 401.Web
/cli/authorize?code=…page:authGuard: the page a signed-out visitor asked for is kept and opened after the console login, which only came back to the root. The kept URL is only a path of the app, used once.Tests
Unit tests: code format, reading a typed code back, cleaning the machine name.