Repository navigation
Use device flow for browser auth - #90
Merged
Merged
Conversation
Replace the loopback callback server in `apitally auth` with a device authorization flow. The CLI creates a login session via the public API, opens the verification URL, prints the code to confirm in the browser, and polls for the API key once the user approves. Remove the hidden --app-url option and the paste API key prompt.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #90 +/- ##
==========================================
+ Coverage 91.67% 91.88% +0.20%
==========================================
Files 13 13
Lines 2523 2477 -46
==========================================
- Hits 2313 2276 -37
+ Misses 210 201 -9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 6 files
This PR changes authentication, authorization, or input validation. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.
Fix all with cubic | Re-trigger cubic
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.
Replaces the loopback callback in
apitally authwith a device authorization flow (modeled on RFC 8628).The browser only approves a login session, and the CLI fetches the API key by polling the public API. This works the same in every browser, over SSH, and in containers or cloud sandboxes.
Flow
POST /v1/cli-auth/sessions(unauthenticated) returns adevice_code, auser_codelikeWDJB-MJHT, averification_url,expires_inandintervalPOST /v1/cli-auth/tokenwith thedevice_code:200: saves the returned API key202,429,5xxor a transport error: keeps polling4xx: fails with "authentication expired"expires_in: fails with "authentication timed out"Changes
browser_authinsrc/auth.rs, and remove the local callback serverapi_post_without_keytosrc/utils.rsfor the unauthenticated session request--app-urloption (APITALLY_APP_URL), because the server builds the verification URL--api-keyandAPITALLY_API_KEYstill cover existing keysVerification
cargo fmt --check,cargo clippyandcargo testpasswritescope, andwhoamisucceeded with it