Repository navigation
feat(cli): Treat SENTRY_AUTH_TOKEN as an account next to stored logins - #1558
Open
sentry-junior[bot] wants to merge 2 commits into
Open
sentry-junior[bot] wants to merge 2 commits into
sentry-junior[bot] wants to merge 2 commits into
Conversation
Closes #1553. An env token whose server is known from a trusted source (its sntrys_ claim, SENTRY_HOST/SENTRY_URL from the boot env, or SaaS) now acts as one more, never stored, read-only account instead of being all-or-nothing: - Org routing uses it for organizations it knows, ahead of stored accounts (the active one included), and server-based selection uses it when no stored account is on the configured server. - `sentry org list` lists its orgs under `env:SENTRY_AUTH_TOKEN`, labeled with its `/auth/` user when available; `--account env:SENTRY_AUTH_TOKEN` selects it. - `sentry auth list` and `sentry auth status` show it with its server and user. `sentry auth switch` can't select it. Tokens set after boot (a `.sentryclirc` token) keep today's fallback-only behavior, and SENTRY_FORCE_ENV_TOKEN still means "use only the env token". Co-Authored-By: byk <burak.kaya@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1eaacd7. Configure here.
The env token's credential fingerprint doesn't depend on its server, so orgs it cached while scoped to another SENTRY_URL could select it for a same-slug org on its current server. Match cached orgs against the token's trusted host (SaaS regions count as SaaS).
This branch was previously deployed
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.

Closes #1553.
Until now, if you had both a stored login and
SENTRY_AUTH_TOKEN/SENTRY_TOKEN, every command ignored one of them. With this change the env token acts as one more account: read-only, never stored, and only sent to its own server. That only happens when its server comes from a trusted source: the token'ssntrys_claim,SENTRY_HOST/SENTRY_URLfrom the boot env, or SaaS when neither is set. Everything else keeps today's behavior.Behavior (follows the answers on the issue: env token wins, switching stays implicit, show the
/auth/user)SENTRY_HOST/SENTRY_URLset, the env token is used for that server when no stored account is on it.sentry org listlists the env token first, asenv:SENTRY_AUTH_TOKEN. An org it shares with a login is listed under it, which matches what routing will pick. The label includes the token's user from/auth/when the server returns one (skipped for org auth tokens).--account env:SENTRY_AUTH_TOKENlists only the env token's orgs. With only an env token, the output doesn't change.sentry auth list/sentry auth statusshow the env token with its server and user.sentry auth switchcan't select it.SENTRY_FORCE_ENV_TOKEN=1still means "use only the env token".Trust model. The env-token host snapshot now records which token was present at boot. A token added later, like a
.sentryclirc[auth] tokencopied in by the shim, isn't scoped by that snapshot, so it doesn't become an account and keeps its fallback-only role.withEnvAccount()(the counterpart ofwithStoredAccount()) runs work under an env copy with the token forced andSENTRY_URLpinned to its trusted host. That way a.sentryclircor pasted URL can't move it to another server.Tradeoff for review. Org routing only learns which orgs the env token can access from the org cache, mostly filled by
sentry org list. Because the env token wins for those orgs, an org auth token (sntrys_) whose org is cached will also be used for that org's non-build commands, where its scopes may be too narrow. That follows from the "env token wins" decision. If it's a problem in practice, we can restrict the precedence to user tokens.via byk.
--
View Junior Session in Sentry