Documentation
¶
Overview ¶
Package broker is the only path that ever sees a secret.
Same inject-at-the-edge pattern as Infisical Agent Vault: the agent calls the real URL (or asks us to); we attach the credential at the edge and return the upstream result. The agent-visible UseResult is scrubbed.
Index ¶
- Variables
- func AssertNoSecret(v any, secret []byte) error
- func EnvName(itemName string) string
- func LogEvent(e protocol.AuditEvent, item, host string, status int)
- func MonthWindow(t time.Time) time.Time
- type Broker
- func (b *Broker) Approve(human protocol.Principal, grantID string, ttl time.Duration) (protocol.Approval, error)
- func (b *Broker) ApproveRequest(human protocol.Principal, reqID string, ttl time.Duration) (protocol.ApprovalRequest, error)
- func (b *Broker) ChildEnv(ctx context.Context, agent protocol.Principal) ([]string, error)
- func (b *Broker) FileRequest(ctx context.Context, agent protocol.Principal, item protocol.Item, ...) (protocol.ApprovalRequest, error)
- func (b *Broker) Use(ctx context.Context, agent protocol.Principal, req protocol.UseRequest) (protocol.UseResult, error)
- func (b *Broker) UseSession(ctx context.Context, sessionHash []byte, req protocol.UseRequest) (protocol.UseResult, error)
- type Clock
Constants ¶
This section is empty.
Variables ¶
var ( ErrOverloaded = errors.New("broker: origin overloaded") )
Functions ¶
func AssertNoSecret ¶
AssertNoSecret marshals v and fails the test helper contract if secret appears.
func EnvName ¶
EnvName is the Infisical vault-run name: item name, uppercased, hyphen to underscore.
Types ¶
type Broker ¶
type Broker struct {
Store store.Store
Auditor audit.Auditor
AuditTimeout time.Duration
HTTP *http.Client
Now Clock
// OnRequestFiled fires once per newly filed approval request — the app
// wires owner notification here. Deduped asks do not re-fire.
OnRequestFiled func(context.Context, protocol.ApprovalRequest)
// FreeUseCap is the per-org per-window use allowance on the free plan —
// the Paper-style gate (VEIL-60). 0 disables metering entirely.
FreeUseCap int64
// AccessCheck is the VEIL-62 billing backstop: on a capped deny it asks
// Vortex whether the org's entitlement is live — a definitive answer
// heals a plan a missed webhook left stale. Caching lives inside the
// implementation; the deny path is the only caller, and any error inside
// the check resolves to false (the local denial stands).
AccessCheck func(ctx context.Context, orgID, customerID string) bool
// contains filtered or unexported fields
}
func NewWithInFlight ¶
NewWithInFlight creates a Broker that allows at most n concurrent Use calls. n <= 0 means unlimited.
func (*Broker) Approve ¶
func (b *Broker) Approve(human protocol.Principal, grantID string, ttl time.Duration) (protocol.Approval, error)
Approve records a human approval for a level-1 grant — approval insert and ask resolution commit together, so a grant can never be approved while its asks still read open. Membership is Keto via App.ApproveOIDC. This store does not decide who is a human.
func (*Broker) ApproveRequest ¶
func (b *Broker) ApproveRequest(human protocol.Principal, reqID string, ttl time.Duration) (protocol.ApprovalRequest, error)
ApproveRequest resolves ONE pending ask: the minted approval lands only while the ask is still open and its grant still live — a lost race (another owner resolved it, it expired, the grant died) writes nothing and returns ErrRequestResolved.
func (*Broker) ChildEnv ¶
ChildEnv injects granted material into a child process. The child sees the secret. Broker stdout, MCP, and audit do not. Level 1 without a live approval is skipped — never a prompt. SSH stays on the agent socket.
func (*Broker) FileRequest ¶
func (b *Broker) FileRequest(ctx context.Context, agent protocol.Principal, item protocol.Item, g *protocol.Grant, action protocol.ActionKind) (protocol.ApprovalRequest, error)
FileRequest turns a need_approval into the ask: one open row per (grant, action), deduped by the store. A fresh file audits request_filed and fires OnRequestFiled once; a deduped refile just returns the live ask.