Type: Feature
Summary
We need to build @vymalo/opencode-repo-auth — the OpenCode plugin that scopes a developer's gateway requests to their repo's Source via audience-scoped token exchange — because that is the client half of epic #64.
Expected result:
A published plugin that, on an enrolled repo, injects a Source-scoped bearer so Authorino bills the request to the repo's Source.
Intent
Give local dev the repo-as-principal attribution CI has, reusing auth-core.
Source of truth (links)
Expected Behavior
- Resolve git
origin → normalized remote (strip user:pass@, normalize scp/https, handle worktrees & missing remote).
- Read the Source id from the repo's
opencode.json (options.meta.repoAuth.sourceId).
TokenRuntime.ensure(human) (device-code/auth-code, offline_access) → exchange(humanToken, audience = <base>/sources/src-XXX).
- Cache the Source-scoped token per Source (
hash(sourceId), OS cache dir, 0o600, atomic rename). Short TTL → re-exchange from the offline root on expiry ("model b").
chat.headers injects Authorization: Bearer <source-token> on the gateway provider only (guard by managed provider id), after any user-bearer.
- Honor the config-object handshake (stamp
provider.options.headers.Authorization at config-time for models-info). Ordering: repo-auth → models-info → ratelimit.
Acceptance Criteria
Out of Scope
auth-core extraction (separate ticket); resolve-by-remote (deferred); monorepo sub-project Sources.
Technical Context
Depends on the auth-core ticket. Mirror the per-package layout; new cache namespace opencode-repo-auth. Sibling reference service: ADORSYS-GIS/lightbridge-repo-auth.
Risks
Exchange aud/refresh semantics (see spike). Mitigate with re-exchange default. Leaking repo URL to non-gateway providers — mitigate with the managed-provider guard.
Test Plan
Unit (remote normalization incl. worktree, cache keying, exchange), integration against a Keycloak stub, manual end-to-end against the gateway.
Verification evidence
To be filled: tests + a live run showing the Source bearer on the gateway provider only.
Human accountable owner
@stephane-segning
AI Usage Declaration
Drafting the ticket, Proposing implementation, Generating code, Generating tests. Verified by owner.
Human verification completed
Type: Feature
Summary
We need to build
@vymalo/opencode-repo-auth— the OpenCode plugin that scopes a developer's gateway requests to their repo's Source via audience-scoped token exchange — because that is the client half of epic #64.Expected result:
Intent
Give local dev the repo-as-principal attribution CI has, reusing
auth-core.Source of truth (links)
docs/adr/0005-…; designplans/git-auth.md.Expected Behavior
origin→ normalized remote (stripuser:pass@, normalize scp/https, handle worktrees & missing remote).opencode.json(options.meta.repoAuth.sourceId).TokenRuntime.ensure(human)(device-code/auth-code,offline_access) →exchange(humanToken, audience = <base>/sources/src-XXX).hash(sourceId), OS cache dir,0o600, atomic rename). Short TTL → re-exchange from the offline root on expiry ("model b").chat.headersinjectsAuthorization: Bearer <source-token>on the gateway provider only (guard by managed provider id), after any user-bearer.provider.options.headers.Authorizationat config-time for models-info). Ordering: repo-auth → models-info → ratelimit.Acceptance Criteria
sourceId, then the plugin no-ops on that provider (no crash).@vymalo/opencode-oauth2(documented + guarded)..,./lib), on the shared version line, docs indocs/,CHANGELOG.mdentry.Out of Scope
auth-coreextraction (separate ticket); resolve-by-remote (deferred); monorepo sub-project Sources.Technical Context
Depends on the
auth-coreticket. Mirror the per-package layout; new cache namespaceopencode-repo-auth. Sibling reference service:ADORSYS-GIS/lightbridge-repo-auth.Risks
Exchange
aud/refresh semantics (see spike). Mitigate with re-exchange default. Leaking repo URL to non-gateway providers — mitigate with the managed-provider guard.Test Plan
Unit (remote normalization incl. worktree, cache keying, exchange), integration against a Keycloak stub, manual end-to-end against the gateway.
Verification evidence
To be filled: tests + a live run showing the Source bearer on the gateway provider only.
Human accountable owner
@stephane-segning
AI Usage Declaration
Drafting the ticket, Proposing implementation, Generating code, Generating tests. Verified by owner.
Human verification completed