verify auth status against the server - #65
Conversation
auth status used to print whatever email login cached at the time, which is wrong the moment the key is revoked or the account goes away, and was blank for keys supplied by hand or by WAVEDASH_TOKEN. GET /api/me returns the owner of the key, so status calls that and prints the username and email it gets back. A 401 is reported as a rejected key with exit 1, pointing at login or the env var depending on where the key came from. Any other failure is reported as unable to verify, still showing the masked key. Nothing reads the cached email any more, so the credentials file stops carrying it. Old files with an email field still load.
|
Claude finished @The64thRealm's task in 4m 40s —— View job Code review
Reviewed commit 4 findings, posted inline:
|
|
Claude finished @The64thRealm's task in 3m 28s —— View job Code review
Reviewed at 3 findings, posted inline:
Checked and deliberately not flagged: dropping Note: · branch |
|
Claude finished @The64thRealm's task in 4m 7s —— View job Code review
Reviewed at 4 findings, posted inline:
Checked and deliberately not flagged: the partial move of Note: |
|
Claude finished @The64thRealm's task in 6m 11s —— View job Code review
Reviewed at Verified the tricky parts hold: removing 4 findings, posted inline:
Still open from earlier passes (unchanged at this head, not re-posted inline to avoid duplicate threads):
Note: |
| .header("Authorization", format!("Bearer {}", api_key)) | ||
| .send() | ||
| .await?; | ||
| if response.status() == reqwest::StatusCode::UNAUTHORIZED { |
There was a problem hiding this comment.
Every 401 is attributed to the API key, including 401s that have nothing to do with it. Staging builds bake in the CF Access creds through option_env! (config.rs:80-81), so a staging binary built without them gets a Cloudflare Access 401 on every request — and auth status then reports "The API key ... was rejected by the server. It may have been revoked, or the account may no longer be active" and tells the user to log in again, which cannot fix a CF Access rejection. Consider only treating a 401 as Rejected when the body is the API's own JSON error (e.g. code == "unauthorized"), and falling through to check_api_response otherwise.
| } | ||
| Ok(()) | ||
| } | ||
| Ok(Verification::Rejected) => anyhow::bail!( |
There was a problem hiding this comment.
--json only produces JSON on the happy path. The three interesting verdicts this PR introduces — not authenticated (line 63), key rejected (here), and could-not-verify (line 87) — all bail! with prose on stderr, so a script doing wavedash auth status --json | jq -r .email gets empty stdout and has to parse English from stderr to tell "revoked key" apart from "server unreachable". Emitting something like {"authenticated": false, "reason": "rejected"} on stdout (still exit 1) in json mode would make the machine-readable mode usable for the case it's most needed.
|
Claude finished @The64thRealm's task in 5m 23s —— View job Code review
Reviewed at Verified the tricky parts hold: dropping 4 findings, posted inline:
Still open from earlier passes (unchanged at this head, not re-posted inline to avoid duplicate threads):
Note: · branch |
auth status used to print whatever email login cached at the time, which is wrong the moment the key is revoked or the account goes away, and was blank for keys supplied by hand or by WAVEDASH_TOKEN