broker

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
var (
	ErrOverloaded   = errors.New("broker: origin overloaded")
	ErrUnauthorized = errors.New("broker: unauthorized")
)

Functions

func AssertNoSecret

func AssertNoSecret(v any, secret []byte) error

AssertNoSecret marshals v and fails the test helper contract if secret appears.

func EnvName

func EnvName(itemName string) string

EnvName is the Infisical vault-run name: item name, uppercased, hyphen to underscore.

func LogEvent

func LogEvent(e protocol.AuditEvent, item, host string, status int)

LogEvent writes a grant event to slog. No secrets, no query string, no body. HTTP request logs are Railway (`railway logs --http`). This is the grant line.

func MonthWindow

func MonthWindow(t time.Time) time.Time

MonthWindow is the UTC calendar month containing t — the billing window a use claims against.

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 New

func New(s store.Store) *Broker

func NewWithInFlight

func NewWithInFlight(s store.Store, n int) *Broker

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

func (b *Broker) ChildEnv(ctx context.Context, agent protocol.Principal) ([]string, error)

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

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.

func (*Broker) Use

Use performs an action for an agent. It never puts a secret on UseResult.

func (*Broker) UseSession

func (b *Broker) UseSession(ctx context.Context, sessionHash []byte, req protocol.UseRequest) (protocol.UseResult, error)

type Clock

type Clock func() time.Time

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL