Skip to content

Proposal: Provider Auth v2 (encrypted credential vault + multi-account OAuth + same-request rotation) #5748

@jroth1111

Description

@jroth1111

Context

I'm the author of the recently opened auth-v2 PRs from a new GitHub account (my prior account lost access). One of the PRs was closed as potential spam — totally fair given the account/volume — so I'm starting an issue to discuss direction first.

The full RFC is in specs/provider-auth-v2.md (included in the PR branches).

Problem

Today's auth path is effectively single-credential and makes it hard to support:

  • multiple OAuth subscription accounts per provider
  • deterministic rotation/cooldowns on 429 within the same user request
  • refresh-on-expired (401/403) where supported
  • a single composable integration point across providers

Proposal (Auth v2)

  • Encrypted-at-rest credential vault (AES-256-GCM) with atomic writes + lockfile coordination.
  • Multi-record credential store (providerId + namespace + label), enabling multiple accounts per provider.
  • Provider auth registry/adapters to unify OAuth flows + apply auth headers for Anthropic/OpenAI/Google/Copilot/Qwen/Cursor.
  • Fetch-level rotation middleware:
    • rotate on 429 (Retry-After-aware) and retry within the same request
    • refresh on 401/403 when supported
    • persist pool ordering + cooldowns
  • Migrate legacy auth files into the new store; keep behavior compatible.

Optional UX/docs pieces:

  • TUI connected-accounts management + rotation stats
  • Opt-in OpenAI-compatible model discovery via /models with caching
  • Vault key management commands (init/export/import)

PRs (if you'd like to review code)

Questions

  1. Is this direction acceptable for OpenCode?
  2. Would you prefer the work reviewed as split PRs or as a single PR?
  3. Any preferences on vault key location / migration strategy / naming before I iterate further?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions