Skip to content

iDeploy: browser sign-in for the CLI (device flow) - #386

Merged
DJTJ21 merged 1 commit into
devfrom
feat/ideploy-cli-device-login
Oct 19, 2026
Merged

DJTJ21 merged 1 commit into
devfrom
feat/ideploy-cli-device-login

Conversation

@DJTJ21

@DJTJ21 DJTJ21 commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Why

First piece of the idem CLI (repo Idem-AI/cli): idem login opens 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

Route Auth Role
POST /api/v1/cli/auth/start { host } public Returns deviceCode (secret, 64 hex), userCode (ABCD-EFGH, no look-alike characters), verificationUrl, expiresIn 600, interval 3
GET /api/v1/cli/auth/requests/:code session The request: machine, status
POST /api/v1/cli/auth/requests/:code { approve } session Approve (issues a PAT "CLI — ", valid one year) or refuse
POST /api/v1/cli/auth/poll { device_code } public pending / approved + token (handed over once, then deleted) / denied / expired
  • The requests live in Redis (10 min TTL). Nothing is written to the database before approval.
  • The router is mounted before the routers on /api/v1 that authenticate everything (like the webhooks). Otherwise start and poll would answer 401.

Web

  • /cli/authorize?code=… page:
    • says which machine is asking;
    • asks to check that the code matches the terminal;
    • shows Authorise / Refuse;
    • warns to approve only a request you started yourself.
  • 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.
  • i18n fr/en.

Tests

Unit tests: code format, reading a typed code back, cleaning the machine name.

- 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).
@DJTJ21
DJTJ21 merged commit 3f4ad57 into dev Oct 19, 2026
9 of 10 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.

1 participant