Skip to content

Fix login URL handling, add Ctrl+C support, add logout command#740

Open
matthiaswenz wants to merge 5 commits intomainfrom
chore/cli-login-fixes
Open

Fix login URL handling, add Ctrl+C support, add logout command#740
matthiaswenz wants to merge 5 commits intomainfrom
chore/cli-login-fixes

Conversation

@matthiaswenz
Copy link
Collaborator

@matthiaswenz matthiaswenz commented Mar 20, 2026

Summary

  • Only use verification_uri: Never open verification_uri_complete — showing one URL but opening another is a phishing vector (an attacker who can tamper with the device auth response could set verification_uri_complete to a lookalike domain). Fixes regression from Use cleaner base URL in login output #728.
  • Handle Ctrl+C: Make the "Press Enter to open..." prompt context-aware so Ctrl+C exits cleanly instead of leaving the process stuck on a blocking tty read
  • Fix double-close bug: waitForEnter called tty.Close() on cancellation while a defer tty.Close() also ran on return — after the first close releases the FD, another goroutine could reuse that FD number and the deferred close would silently close an unrelated file
  • Browser fallback URL: When the browser fails to open, print the approval URL so the user can copy-paste it
  • Add entire logout: Removes stored credentials from the OS keyring, fully reversing entire login

Test plan

  • Unit tests pass (mise run test:ci)
  • Manual: run entire login, verify the same URL is shown and opened in browser
  • Manual: run entire login, hit Ctrl+C at the prompt — verify clean exit
  • Manual: run entire login with browser unavailable — verify URL is printed for copy-paste
  • Manual: run entire logout — verify "Logged out." message and token removed from keyring

🤖 Generated with Claude Code

matthiaswenz and others added 2 commits March 20, 2026 08:22
- Show clean verification_uri to the user, but open
  verification_uri_complete (with code pre-filled) in the browser
- Make waitForEnter context-aware so Ctrl+C exits cleanly instead of
  leaving the process stuck on a blocking tty read

Fixes regression from #728 where the browser-opened URL lost the
auth code parameter.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 1518a16ea037
Adds `entire logout` which deletes the auth token from the OS keyring,
fully reversing `entire login`.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 43f1c3795354
Copilot AI review requested due to automatic review settings March 20, 2026 07:22
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

select {
case <-ctx.Done():
// Close tty to unblock the reading goroutine.
_ = tty.Close()
Copy link

Choose a reason for hiding this comment

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

Double close of tty file descriptor

Medium Severity

In waitForEnter, when the context is cancelled, tty.Close() is called explicitly on line 200 to unblock the reader goroutine, but defer tty.Close() on line 188 will also run when the function returns. This double-close of tty is a correctness bug — after the first close releases the file descriptor, another goroutine could reuse that FD number, and the deferred close would then silently close an unrelated file.

Additional Locations (1)
Fix in Cursor Fix in Web

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes entire login’s device-auth URL handling and interrupt behavior, and adds a logout command to remove stored credentials from the keyring.

Changes:

  • Print the clean verification_uri but open verification_uri_complete in the browser during login.
  • Make the “Press Enter…” prompt context-aware to respond to Ctrl+C.
  • Add entire logout to delete the stored token from the OS keyring (plus basic command registration tests).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
cmd/entire/cli/root.go Registers the new logout subcommand on the root command.
cmd/entire/cli/logout.go Implements entire logout by deleting the token from the keyring for the current base URL.
cmd/entire/cli/logout_test.go Adds tests for logout output/registration/Short description (currently non-hermetic).
cmd/entire/cli/login.go Splits display vs browser URLs; makes the enter prompt cancellable via context.

matthiaswenz and others added 2 commits March 20, 2026 08:32
When the browser fails to open, print the full verification URL (with
code pre-filled) so the user can copy-paste it directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 6e7deeb97fd7
Extract runLogout with a tokenDeleter interface so tests use a mock
instead of the real OS keyring, preventing failures on CI.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 1d26a3e7f936
@matthiaswenz matthiaswenz marked this pull request as ready for review March 20, 2026 07:57
@matthiaswenz matthiaswenz requested a review from a team as a code owner March 20, 2026 07:57
dipree
dipree previously approved these changes Mar 20, 2026
Showing one URL but opening another is a phishing vector — an attacker
who can tamper with the device auth response could set
verification_uri_complete to a lookalike domain while the clean
verification_uri looks legitimate in the terminal.

Always show and open the same URL. The server can handle pre-filling
the device code on its end.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: d9afebaaf0f8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants