Repository navigation
refactor(auth): refresh dcd login sessions through the API, not Supabase - #313
Merged
Merged
Conversation
…abase The CLI refreshed its session by calling Supabase Auth with a publishable key fetched from the API. It now posts the refresh token to the API's POST /cli-login/refresh, which does the refresh server-side. - 401 (Supabase refused the token) and 400 are final: run `dcd login`. The friendly messages for session_expired / session_not_found / refresh_token_not_found are kept. - Network errors, 404, 429 and 5xx keep the stored session for a retry. - Sends the CLI identity headers, like every other API call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Code reviewSkipped: this PR is still a draft (the description says it stays a draft until the API's 🤖 Generated with Claude Code |
A 200 whose body is not JSON (a proxy page, say) made res.json() throw a plain SyntaxError. It now throws a retryable SessionRefreshError, like the other might-work-later cases, so the user sees a clear message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
riglar
marked this pull request as ready for review
November 17, 2026 11:55
Contributor
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
Merged
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.
What
The CLI refreshed its
dcd loginsession by calling Supabase Auth directly, with a publishable key fetched from the API. It now posts the refresh token to the API'sPOST /cli-login/refresh, and the API does the refresh.This is the second step in moving the CLI's auth off direct Supabase calls (the first was #312). After this,
dcd loginsessions need no Supabase key at all.How errors map
dcd login. The existing friendly messages forsession_expired,session_not_foundandrefresh_token_not_foundare keptA failed refresh never deletes the stored session. That hasn't changed.
The request also carries the CLI's identity headers (
x-dcd-cli-versionand the CI headers), like every other API call.Draft until the API endpoint is live in production. A CLI released before then would get a 404 on every refresh. The 404 is treated as retryable, so nobody is logged out, but sessions would stop renewing after an hour.
Testing
test/unit/cli-auth-gateway.test.tscovers the request shape, the success path, each refusal message, and every retryable case.supabase-key.test.ts.pnpm typecheck,pnpm lint,pnpm test:unit(573 passing).🤖 Generated with Claude Code