-
Notifications
You must be signed in to change notification settings - Fork 21
feat: support VIP_CLI_TOKEN environment variable for keychain-free authentication #2946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,31 @@ | ||
| import chalk from 'chalk'; | ||
|
|
||
| import http from '../lib/api/http'; | ||
| import tokenCache from '../lib/rechallenge/token-cache'; | ||
| import Token from '../lib/token'; | ||
| import Token, { ENV_TOKEN_NAME } from '../lib/token'; | ||
| import { trackEvent } from '../lib/tracker'; | ||
|
|
||
| export default async (): Promise< void > => { | ||
| try { | ||
| await http( '/logout', { method: 'post' } ); | ||
| // VIP_CLI_TOKEN is user-managed: logout must not invalidate it server-side. | ||
| if ( ! Token.isEnvTokenSet() ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When both stored token A and environment token B exist, logout skips server revocation but deletes A from the keychain (see the AC: Mixed-source logout neither revokes B nor silently deletes an unrevoked A. |
||
| await http( '/logout', { method: 'post' } ); | ||
| } | ||
| } finally { | ||
| await Token.purge(); | ||
| await tokenCache.clearAll(); | ||
| } | ||
|
|
||
| // Purging the keychain does not clear the env var, so the CLI would remain | ||
| // authenticated via VIP_CLI_TOKEN. Tell the user how to fully log out. | ||
| if ( Token.isEnvTokenSet() ) { | ||
| console.log( | ||
| chalk.yellow( | ||
| `Note: ${ ENV_TOKEN_NAME } is still set in your environment and continues to authenticate ` + | ||
| `VIP-CLI. Unset ${ ENV_TOKEN_NAME } to fully log out.` | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| await trackEvent( 'logout_command_execute' ); | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An expired or claim-invalid but decodable environment token enters the login flow. The replacement is stored in the keychain, but subsequent requests reread and send the still-authoritative environment token.
We must treat every invalid environment token as an actionable configuration error rather than offering keychain login.
Acceptance criteria: Expired and claim-invalid VIP_CLI_TOKEN values exit without prompting, name the variable, and explain how to replace or unset it.