Repository navigation
Show native OAuth project limits in auth status - #325
Conversation
yummybomb
left a comment
There was a problem hiding this comment.
two credential issues to address:
pkg/auth/storage.go:28—projectscan push credentials past the windows keyring's 2,560-byte limit. login reports success after saving to disk, but the next command still reads the old keyring entry. make the successful fallback authoritative.cmd/auth.go:181— project-limited native logins saved by older cli versions still showorganization-wideuntil refresh. show the scope as unknown when it wasn't recorded, and point users tokernel login --force.
…d show an unrecorded scope as unknown
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort 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 26a80d1. Configure here.
|
@yummybomb thanks, both addressed (26a80d1, 08ad67f):
|
yummybomb
left a comment
There was a problem hiding this comment.
the two original cases are covered: a newly saved disk fallback wins over a stale keychain entry, and older credentials no longer claim organization-wide scope when it wasn’t recorded. make test and go test -race ./pkg/auth passed on linux with a temporary home.
three things to fix before merge: preserve the active account on upgrade, avoid losing both copies during overlapping saves, and isolate the credential files in tests.
…d keep the keychain when neither copy is stamped
…native-projects # Conflicts: # pkg/auth/oauth_test.go

Summary
kernel auth statusdecides its "Access scope" line from the token response'saccess_scopeandproject_id. Tokens from the native authorization server limit a grant to chosen projects through its policy and list them in a separateprojectsfield, withaccess_scope: organizationand noproject_id. The CLI ignored that field, so a sign-in limited to one project showed "organization-wide". Enforcement was already correct; only the display was wrong.projectsfrom the token response on login, and keep it across refreshes that omit it.auth statusshowsproject <id>for one project,projects <id>, <id>for several, andorganization-wideonly when the grant isn't limited.access_scope: project) display as before.Testing
go test ./pkg/auth/ ./cmd/: new tests for storing projects on exchange and keeping them on refresh, and for the scope label.Note
Medium Risk
Touches authentication storage, refresh, and multi-process locking; bugs could break login or cause race-related refresh failures, but behavior is heavily tested.
Overview
kernel auth statusnow derives Access scope from storedprojects(native grants withaccess_scope: organization) viaaccessScopeLabel, with legacyproject_idunchanged and an unknown hint for credentials saved before scope was recorded. Debug output usestokens.Sourceinstead of probing the keyring directly.OAuth login and refresh persist
ProjectsandScopeRecordedfrom token responses, and refresh keeps project lists when the response omits them.Credential I/O is serialized with a cross-process lock file (
withCredentialsLock);refreshStoredTokensre-loads under that lock so parallel CLI processes refresh once and avoid reusing consumed refresh tokens. Save/load stampsSavedAt, prefers the newer keyring vs file copy, and cleans up stale keyring entries when falling back to disk.New tests cover scope labels, project persistence, concurrent save/refresh, and lock behavior.
Reviewed by Cursor Bugbot for commit 17026d0. Bugbot is set up for automated code reviews on this repo. Configure here.