Skip to content

fix: route live-mode keys to keyring and store account ID on interactive login#1509

Merged
bernerd-stripe merged 3 commits intomasterfrom
bernerd/fix-interactive-login-key-routing
Mar 25, 2026
Merged

fix: route live-mode keys to keyring and store account ID on interactive login#1509
bernerd-stripe merged 3 commits intomasterfrom
bernerd/fix-interactive-login-key-routing

Conversation

@bernerd-stripe
Copy link
Copy Markdown
Contributor

Reviewers

r? @
cc @stripe/developer-products

Summary

stripe login --interactive had two bugs compared to the browser login path:

  1. Live-mode keys stored as plaintext test-mode keys. The key entered
    interactively was unconditionally assigned to Profile.TestModeAPIKey,
    even for sk_live_ / rk_live_ keys. Test-mode keys are stored in
    plaintext in config.toml. Live-mode keys should go to
    Profile.LiveModeAPIKey, which writeProfile stores redacted in config
    and in full in the system keyring.

  2. Account ID never stored. The /v1/account response was used only to
    extract the display name; account.ID was discarded. The browser login
    path stores the account ID on the profile; interactive login now does too.

Changes:

  • pkg/login/interactive_login.go: detect key prefix (sk_live_/rk_live_)
    and route to the correct profile field; store both DisplayName and
    AccountID from the single GetUserAccount call. Remove getDisplayName
    (was a wrapper that discarded the account ID). Extract
    interactiveLoginWithParams to enable testing with injected reader/baseURL.

  • pkg/login/interactive_login_test.go: replace the now-deleted
    getDisplayName tests with three new InteractiveLogin tests covering
    test-mode key routing, live-mode key routing, and account ID + display name
    storage.

Backward compatibility: Existing users with live keys incorrectly stored
as test-mode keys are unaffected — their config continues to work as-is. On
their next stripe login --interactive, CreateProfile wipes and rewrites
the profile section, routing the live key to the keyring going forward.

…ive login

`stripe login --interactive` was unconditionally storing the entered key
as a test-mode key in plaintext. Live-mode keys (sk_live_/rk_live_) now
route to LiveModeAPIKey so writeProfile stores them redacted in config and
in the system keyring. The account ID from GET /v1/account is now stored
on the profile, matching the browser login path.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Committed-By-Agent: claude
@bernerd-stripe bernerd-stripe requested a review from a team as a code owner March 23, 2026 22:32
@bernerd-stripe bernerd-stripe merged commit 6d1403f into master Mar 25, 2026
13 checks passed
@bernerd-stripe bernerd-stripe deleted the bernerd/fix-interactive-login-key-routing branch March 25, 2026 17:51
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