You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[MOCA SBX] Credential keyed by (identity, host), resolved from MOCA's token endpoint #1478
Priority: P0 · Part of the Cortex × MOCA SBX epic · #905 breakdown step 1 · MOCA contract: MI1 §8.5 item 5, §6.3
Problem
Each user has their own credentials, such as a GitHub token or a model API key. The proxy must pick that user's credential for that destination host, and never send it to any other host.
What Cortex does today
static-inject supports only key_by: host | static (staticinject/plugin.go:21-25), from one secret_dir per process (:43). That gives one credential per host per Cortex.
The Placeholder field is a single literal equality gate (:57-61, :193), not a lookup key.
token-exchange exchanges the inbound bearer (tokenexchange/plugin.go:665), so a real bearer would have to live inside the guest. That is exactly what SBX avoids.
Placeholder resolution reads pctx.Shared (:746-756), which is in-process state, not a token endpoint.
What MOCA needs
(grant, host) → credential, through MOCA's control-plane token endpoint. It is RFC 8693-shaped, so token-exchange machinery can be reused, with the connection identity as the subject (issue 1). The guest's bearer is never used.
Results cached per (identity, audience).
A credential is only ever sent to a host in its destination.hosts.
no_credential → 401 with zero upstream requests.
Design questions
Extend static-inject with key_by: identity plus a resolver that calls the endpoint, or extend token-exchange so its subject comes from pctx.Identity?
Cache invalidation on Rebind (a new grant) and on grant expiry mid-connection.
Failure mode when the endpoint is unreachable: fail closed with a named code.
Replaced by #2088 (the credential-resolver seam and moca's resolver), under #2042. Note: this issue says moca's endpoint is RFC 8693-shaped. The code does not match. moca's endpoint takes {"sandbox","host"} and returns {subject, ttlSeconds, credentials[]} (remote-worker/internal/egress/cpcreds.go:223-262).
Correction to my closing comment above. I wrote that this issue's RFC 8693 shape "does not match the code". That was wrong about intent.
The RFC 8693 shape is MI1 §6.3's designed multi-tenant endpoint for harness sessions: POST /internal/token, with the grant as subject_token, callable only by the egress proxy. MI1 shaped it so that Cortex's token-exchange plugin can call it unchanged. It is not built yet.
The endpoint that exists today, POST /v1/egress/credential with the host's token, is the sandbox service's phase 1 (docs/specs/2026-10-26-sbx-egress-credentials-design.md §4.2, ADR-0046). Its phase 2 (§9, owed) adds the user's sandbox token to the same request.
#2088 (the resolver seam) and #2090 (grants and grant-bound lookups on both paths) now say this. This issue stays closed as replaced by them.
Activity
huang195 commentedon Nov 23, 2026
Replaced by #2088 (the credential-resolver seam and moca's resolver), under #2042. Note: this issue says moca's endpoint is RFC 8693-shaped. The code does not match. moca's endpoint takes {"sandbox","host"} and returns {subject, ttlSeconds, credentials[]} (remote-worker/internal/egress/cpcreds.go:223-262).
huang195 commentedon Nov 23, 2026
Correction to my closing comment above. I wrote that this issue's RFC 8693 shape "does not match the code". That was wrong about intent.
POST /internal/token, with the grant assubject_token, callable only by the egress proxy. MI1 shaped it so that Cortex'stoken-exchangeplugin can call it unchanged. It is not built yet.POST /v1/egress/credentialwith the host's token, is the sandbox service's phase 1 (docs/specs/2026-10-26-sbx-egress-credentials-design.md§4.2, ADR-0046). Its phase 2 (§9, owed) adds the user's sandbox token to the same request.#2088 (the resolver seam) and #2090 (grants and grant-bound lookups on both paths) now say this. This issue stays closed as replaced by them.