Skip to content

feat(auth): PKCE on the device login flow - #2

Closed
Zingzy wants to merge 1 commit into
mainfrom
feat/device-auth-pkce
Closed

Zingzy wants to merge 1 commit into
mainfrom
feat/device-auth-pkce

Conversation

@Zingzy

@Zingzy Zingzy commented Jul 18, 2026

Copy link
Copy Markdown
Member

Adds PKCE to spoo login, which the backend now requires on every device authorization.

What changed

  • Generate a fresh S256 verifier/challenge pair per login (internal/auth/pkce.go). The verifier is a 43-char base64url string (32 random bytes), the minimum RFC 7636 length.
  • GET /auth/device/login now carries code_challenge and code_challenge_method=S256 alongside the existing app_id, redirect_uri, and state.
  • DeviceFlow.Run returns the one-time code together with the verifier; ExchangeDeviceCode sends code_verifier in the POST /auth/device/token body.

Compatibility

Older CLI builds fail at the new login step with the backend's "update the app" error page. Nothing else in the flow changes: the loopback callback, state check, and stored token shape are untouched, and existing sessions keep working.

Testing

go build ./..., go vet ./..., and go test ./... all pass. New tests cover the PKCE derivation (including the RFC 7636 Appendix B fixed vector), that the login URL carries a 43-char S256 challenge, that the returned verifier hashes to it, and that the exchange body includes code_verifier.

Pairs with the backend change (spoo-me/spoo#260).

Generate an S256 verifier/challenge pair at login, pass the challenge to
/auth/device/login, and redeem the one-time code with the verifier at
token exchange. The backend now requires this on every device login.
Copilot AI review requested due to automatic review settings July 18, 2026 08:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Zingzy, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 54 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 815f5458-7d4f-4948-9434-fee8b2690b93

📥 Commits

Reviewing files that changed from the base of the PR and between d436ffe and 37dcdbd.

📒 Files selected for processing (7)
  • internal/api/auth.go
  • internal/api/auth_test.go
  • internal/auth/device.go
  • internal/auth/device_test.go
  • internal/auth/pkce.go
  • internal/auth/pkce_test.go
  • internal/cmd/auth.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/device-auth-pkce

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Zingzy

Zingzy commented Jul 18, 2026

Copy link
Copy Markdown
Member Author

Closing as a duplicate. This was opened by a background agent that did not see the already-open PR. The canonical PR with the same change (and more) is #1. Reopen if needed.

@Zingzy Zingzy closed this Jul 18, 2026
@Zingzy
Zingzy deleted the feat/device-auth-pkce branch July 18, 2026 08:26
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.

2 participants