Skip to content

Introduce a CLI-owned Store interface for token storage#5383

Merged
renaudhartert-db merged 1 commit into
mainfrom
cli-storage-cache-interface
May 31, 2026
Merged

Introduce a CLI-owned Store interface for token storage#5383
renaudhartert-db merged 1 commit into
mainfrom
cli-storage-cache-interface

Conversation

@renaudhartert-db
Copy link
Copy Markdown
Contributor

@renaudhartert-db renaudhartert-db commented May 31, 2026

What is this about?

The CLI's token storage is currently shaped by the SDK's TokenCache interface. That interface is internal to the SDK's user-to-machine (U2M) login flow and only carries a bare OAuth token keyed by a string, so there is no room to store anything alongside a token, and the CLI's storage is coupled to an SDK type that exists specifically for U2M login.

This PR introduces a CLI-owned Store interface (Put, Lookup, Delete) over an explicit Entry envelope that wraps the token. A small adapter, ToU2MTokenCache, presents a Store to the SDK at the one place that still requires the SDK interface: passing a cache to u2m.PersistentAuth. The file and keyring backends now implement Store, and the OAuth helpers adapt it for the U2M paths.

This is a structural change with no behavior change. The Entry only holds the token; the point is that it can now grow additional fields without changing the interface or depending on the SDK. The first such field will be a config checksum used to invalidate a cached token when its profile changed, which arrives with a later change that adds caching for machine-to-machine (M2M) and OIDC tokens.

Naming note for reviewers: the new interface is named Store to distinguish the CLI's durable storage from the SDK's transient Cache. The concrete types and helpers in this package are intentionally left in the old vocabulary (fileTokenCache, keyringCache, and so on) in this PR to keep the diff focused on the structural change. A follow-up PR will take care of renaming.

Testing

Existing auth unit and acceptance tests pass; there are no output or behavior changes.

@renaudhartert-db renaudhartert-db changed the title auth: introduce CLI-owned Store interface for token storage Introduce a CLI-owned Store interface for token storage May 31, 2026
Introduce a CLI-owned Store interface (Put/Lookup/Delete) over an explicit Entry envelope around the OAuth token, decoupling the CLI's token storage from the SDK's U2M-internal TokenCache. A thin ToU2MTokenCache adapter presents a Store to the SDK at the one seam that requires it (u2m.PersistentAuth). The file and keyring backends now implement Store.

Structural scaffolding only, no behavior change. The Entry envelope ships holding just the token; it can grow additional fields (e.g. a config checksum for token invalidation) without touching the interface or the SDK. Concrete type names are intentionally left in the old Cache vocabulary; a follow-up uniformizes them to the Store vocabulary.

Co-authored-by: Isaac
@eng-dev-ecosystem-bot
Copy link
Copy Markdown
Collaborator

Commit: b4a4a55

Run: 26716831600

Copy link
Copy Markdown
Member

@simonfaltum simonfaltum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings. Reviewed the Store refactor and SDK adapter call sites; focused tests passed locally: go test ./cmd/auth ./libs/auth ./libs/auth/storage.

@renaudhartert-db renaudhartert-db added this pull request to the merge queue May 31, 2026
Merged via the queue into main with commit a649259 May 31, 2026
25 checks passed
@renaudhartert-db renaudhartert-db deleted the cli-storage-cache-interface branch May 31, 2026 18:19
@eng-dev-ecosystem-bot
Copy link
Copy Markdown
Collaborator

Commit: a649259

Run: 26720654272

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants