EgressPolicy: option to add a credential header when the request has none

Aperta
#3,306 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go, kubernetes, yaml

Direzione di ricerca

Start with substrate/cmd/atenet/internal/router/egress/credentials.go and docs/architecture/egress-policies.md, which the issue names. Trace how applyEffects handles a missing credential header and how destinations[].authentication is represented and validated; then check the egress policy tests. Done means an opt-in inject: Always adds the configured header when absent, replaces it when present, and leaves the default behavior unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What we're trying to do

We run Kagent agents that work on a git repository. An agent's EgressPolicy
opens https://github.com with authentication that injects a GitHub token as
Authorization: Basic …, so the agent can git clone and git push without
the token ever entering the sandbox.

The problem

The egress gateway only replaces a credential header the request already
carries. It never adds a missing one (applyEffects in
substrate/cmd/atenet/internal/router/egress/credentials.go, and
docs/architecture/egress-policies.md). Plain git, npm, pip or curl send no
Authorization header, so the credential is never used.

Every client then has to be configured to send a placeholder:

  • A static placeholder (for example git's http.<url>.extraHeader) is sent
    on every request. Where the agent has no credential, the placeholder goes
    out unchanged. GitHub answers a bad credential with 401 even on public
    repositories, so anonymous clones break.
  • A placeholder that is sent only after a 401 (a git credential helper) works
    for git, but it's a shell snippet per client, and other clients have no
    equivalent.
  • Neither can be set per agent, because Kagent sets env per Harness, not per
    Agent or AgentTemplate.

Proposal

An opt-in setting on destinations[].authentication that makes the gateway
add the header when the request doesn't carry one, and still replace it when
it does. For example:

spec:
  destinations:
    - origin: https://github.com
      authentication:
        header: Authorization
        prefix: "Basic "
        secretKeyRef: {name: repo-token, key: git}
        inject: Always   # default: IfPresent (today's behavior)
  • The default stays as it is, so nothing changes for existing policies.
  • The gateway already writes the header with OVERWRITE_IF_EXISTS_OR_ADD, so
    this changes only the check that skips requests without the header.
  • authentication already requires an exact origin, so Always only covers
    hosts an administrator named explicitly.

With this, any client in the sandbox authenticates to an allowed origin
without configuration or placeholders. The credential still never enters the
sandbox.

Alternatives considered

  • Per-Agent env on AgentTemplate, which would let each agent get its own
    placeholder configuration. It's still per client, and it was deferred
    before.
  • Harness per credential set: it multiplies Harnesses and sandboxes for what
    is policy, not runtime.

Happy to contribute a PR if the direction is acceptable.

Lingua principale
Go
Stelle
4.2k
Fork
890
Merge medio
1g 10h
PR unite (30g)
171

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di kagent-dev/kagent

Tutte le issue di kagent-dev/kagent

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.