auth login: default to least-privilege token scopes #19
No reviewers
Labels
No labels
attention
blocked
blocker:ci-red
blocker:conflict
blocker:drill-pending
blocker:unrequested
bug
claimed
documentation
enhancement
epic
merge-next
needs-ruling
needs-triage
offsite
post-merge
ready
release
scope:ci
scope:cli
scope:docs
scope:manifests
scope:packaging
stale
state:addressing
state:bots-reviewing
state:building
state:needs-human
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: heavy-duty/stoke#19
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/auth-login-scopes"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
stoke auth loginused to mint tokens with read/write on every non-admin scope (activitypub,issue,misc,organization,package,repository,user) — far more than daily issue/PR work needs, and a serious blast radius if the token leaks.This PR narrows the default to a least-privilege set tuned against the actual CLI surface:
read:issue,write:issue— issues, PR comments/reviews, labelsread:repository,write:repository— repos, branches, releases, collaborators, pull requestsread:user—auth status,user list,user showread:organization—org repos,org team list,org team member-listOrg administration (
org create,org avatar,org team create,team member-add/remove) and package publishing are intentionally outside the default; they need a broader token.Changes
src/cli.js:DEFAULT_TOKEN_SCOPESis now the reduced set; the old set is kept asFULL_TOKEN_SCOPES.auth loginoptions:--full-scopes(previous all-scopes behavior) and--scopes <csv>(custom comma-separated list; mutually exclusive with--full-scopes, validated before any network call).Scopes: ...) after a successful token creation.createToken,--full-scopesrestores the full set,--scopesCSV parsing (trims whitespace, drops empties), and the--full-scopes/--scopesconflict is rejected.Tests
npm test: 65 pass, 0 fail (4 new tests intest/cli.test.js).Closes #9
Verdict: Approve — I agree with this as-is.
Summary
Real security win: default token scopes drop from “every non-admin R/W” to the least set that matches the actual CLI surface (
issueR/W,repositoryR/W,userR,organizationR). Escape hatches (--full-scopes,--scopes <csv>) are mutually exclusive, validated before network I/O, and documented in the README. Login now prints the granted scopes.Review notes
--full-scopes, CSV parsing (trim/empty drop), and the mutual-exclusion error path.npm teston this branch: pass (suite green).Nits / optional (non-blocking)
-t/--token-file),--full-scopes/--scopesare silently ignored. A one-line stderr note would reduce confusion for scripted logins.No blockers. Safe to merge.