Repository navigation
feat(cli): Add token commands for org auth tokens - #1647
Open
sentry-junior[bot] wants to merge 4 commits into
Open
sentry-junior[bot] wants to merge 4 commits into
sentry-junior[bot] wants to merge 4 commits into
Conversation
Add `sentry token list`, `sentry token create`, and `sentry token delete` for managing org auth tokens (the org:ci tokens used for source map, debug file, and release uploads). `sentry tokens` aliases `token list`. Sentry only lets OAuth application tokens holding `org:tokens` manage org auth tokens (getsentry/sentry#128051). `org:tokens` stays out of the default login scopes so `sentry auth login` keeps working against older self-hosted servers that don't know it. Instead, `ensureScopesForAction` now requests scopes outside the defaults on demand: the device flow asks for the defaults, the known opt-in scopes the grant already holds, and the scopes the action needs. Creating a token also needs `org:ci` (an OAuth caller can only mint scopes it holds), and revoking one needs `org:write`. Co-Authored-By: BYK <burak.kaya@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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 a206a7f. Configure here.
--dry-run disables interactive prompts, so a dry run of token delete on a login without org:tokens can't elevate and the token lookup fails with 403. Say that --dry-run is one of the flags that skips re-authorization.
Member
|
just seeing this now, i'll get to it today! |
Member
|
found two things while reviewing and fixed them in ac0edfd:
added regression coverage for both; all 77 targeted tests pass. |
This branch was successfully 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.

Adds
sentry token list,sentry token create, andsentry token deletefor org auth tokens (theorg:citokens used for source map, debug file, and release uploads).sentry tokensis an alias fortoken list. This is the CLI side of getsentry/sentry#128051, and replaces the archived getsentry/cli#1112.Scopes
Sentry only lets OAuth application tokens that hold
org:tokensmanage org auth tokens. Personal tokens, org tokens, andSENTRY_AUTH_TOKENget a 403. Here's what each endpoint requires, checked against the merged backend:org:tokens+org:readorg:tokens+org:read+org:ci(an OAuth caller can only mint scopes it holds)org:tokens+org:read+org:write(the delete isorg:write, the confirm lookup isorg:read)org:tokensis now inSENTRY_SCOPES, soauth login --scope org:tokensvalidates. I kept it out of the defaultOAUTH_SCOPESon purpose. The device flow rejects the whole request when it sees a scope it doesn't know, so addingorg:tokensto the defaults would breaksentry auth loginon older self-hosted servers.Instead, each token command calls
ensureScopesForAction, and it can now ask for scopes outside the defaults:requiredonly names default scopes, nothing changes: the device flow requests the defaults.required.When elevation is needed but this run can't do it (no TTY,
--yes, or--json), a 403 gets a specific explanation: what to run once interactively, or that the command needs a CLI login plus an org role that allows it.Notes for review
getControlSiloUrl(). They aren't in@sentry/api(checked 0.399.0), soOrgAuthTokenSchemais a Valibot schema that mirrors the backend serializer.createoutput, including--json, because Sentry can't return it again.listshows onlytokenLastCharacters.deletereads the list to show the token name in the confirmation, since there's no single-token GET. The list is unpaginated server-side.createsplitsorg/nameon the first/, but only when the prefix looks like an org slug. Names containing/work as long as the org is given explicitly.Tests
scope-recovery.typecheck,lint,check:docs-sections,check:destructive,check:fragments, andcheck:errorspass.mainin my sandbox, so they're environment issues unrelated to this change.via BYK.
--
View Junior Session in Sentry