Skip to content

[MOCA SBX] Credential keyed by (identity, host), resolved from MOCA's token endpoint #1478

Not planned

Description

@pdettori

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

  1. 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?
  2. Cache invalidation on Rebind (a new grant) and on grant expiry mid-connection.
  3. Failure mode when the endpoint is unreachable: fail closed with a named code.

Done when

Activity

  1. added
    enhancement
    on Oct 22, 2026
  2. huang195 commented on Nov 23, 2026

    @huang195
    Member

    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).

  3. huang195 commented on Nov 23, 2026

    @huang195
    Member

    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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions