Documentation
¶
Overview ¶
Package identitybroker is the in-process core of the agent identity broker.
Service is the contract for the whole identity broker: Mecatl calls it, and only it, whether the broker runs in process or as its own service. Core is the broker side of that contract, with the authenticated workload on every call; NewInProcess joins the two through an Authenticator. Broker is the Core, and package conformance holds the contract tests every implementation passes.
New validates explicitly supplied configuration, an ECDSA P-256 (ES256) signing capability, and already-loaded definition records, and returns a Broker holding an independently owned snapshot of them, and no broker sessions. The broker signs agent credentials (JWT-SVIDs) with the signer and verifies them itself, for Mecatl's calls and for AS-1. Each agent instance has its own identity: an opaque ag_ identifier given when it first registers, and the SPIFFE ID spiffe://<trust domain>/agent/<ag_ identifier>. A new instance's definition must be one in the snapshot. The snapshot holds only definitions the broker loads itself, operator-loaded global definitions and system built-ins; repository definitions never enter it.
ClientAssertionSigner mints the client assertions the broker authenticates with at AS-1 and AS-2, with the broker client key, separate from the agent issuer key; the token-endpoint client is an adapter. With WithAuthServer, session open converts the user's access token at AS-1 through that adapter into a refresh token the session holds. With WithGateway, AuthorizeCall authorizes each MCP gateway call with its own gateway token: it exchanges the session's refresh token at AS-1 (IDJAGIssuer) for an ID-JAG, records it (Recorder), and redeems it at the gateway's AS-2 (GatewayAuthServer), bound with BindGatewayAS2. The package performs no file, environment, or network access; source loading and transport belong in adapters that call it.
Index ¶
- Constants
- Variables
- func ActorIssuer(trustDomain string) string
- func CheckRegistration(reg Registration) error
- func IsConfigurationFault(err error) bool
- func IsUnavailable(err error) bool
- func ValidToolCallID(id string) bool
- func ValidateGatewayEntries(entries []GatewayEntry) error
- func ValidateTrustDomain(td string) error
- type AgentRef
- type AuthServer
- type Authenticator
- type Authorization
- type AuthorizeCallRequest
- type BeginScheduleSetupRequest
- type Broker
- func (b *Broker) AuthorizeCall(ctx context.Context, workload Workload, req AuthorizeCallRequest) (Authorization, error)
- func (b *Broker) BeginScheduleSetup(ctx context.Context, workload Workload, req BeginScheduleSetupRequest) (ScheduleSetup, error)
- func (b *Broker) BindGatewayAS2(as2 GatewayAS2) (unbind func(), err error)
- func (b *Broker) CancelScheduleSetup(_ context.Context, workload Workload, req CancelScheduleSetupRequest) error
- func (b *Broker) Close(ctx context.Context) error
- func (b *Broker) CloseSession(_ context.Context, workload Workload, req CloseSessionRequest) error
- func (b *Broker) CompleteScheduleSetup(ctx context.Context, workload Workload, req CompleteScheduleSetupRequest) (CompletedScheduleSetup, error)
- func (b *Broker) Definition(ref DefinitionRef) (DefinitionRecord, bool)
- func (b *Broker) FindSchedule(_ context.Context, workload Workload, req FindScheduleRequest) (ScheduleStatus, error)
- func (b *Broker) FindSession(ctx context.Context, workload Workload, req FindSessionRequest) (Session, bool, error)
- func (b *Broker) OpenSession(ctx context.Context, workload Workload, req OpenSessionRequest) (Session, error)
- func (b *Broker) RegisterAgent(ctx context.Context, workload Workload, req RegisterAgentRequest) (Registration, error)
- func (b *Broker) ReportCall(_ context.Context, workload Workload, req ReportCallRequest) error
- func (b *Broker) ReportDelegation(ctx context.Context, workload Workload, req ReportDelegationRequest) error
- func (b *Broker) RevokeSchedule(_ context.Context, workload Workload, req RevokeScheduleRequest) error
- func (b *Broker) VerifyCredential(_ context.Context, req VerifyCredentialRequest) (VerifiedAgent, error)
- func (b *Broker) VerifyCredentialForOwner(_ context.Context, req VerifyCredentialForOwnerRequest) (VerifiedAgent, error)
- type CallEntryCheck
- type CallReport
- type CallTarget
- type CancelScheduleSetupRequest
- type Ceiling
- type CeilingServer
- type ClientAssertionSigner
- type CloseCause
- type CloseSessionRequest
- type Code
- type CompleteScheduleSetupRequest
- type CompletedScheduleSetup
- type Config
- type Core
- type CredentialRef
- type CredentialVerifier
- type DecisionOutcome
- type DecisionRecord
- type DefinitionRecord
- type DefinitionRef
- type DefinitionTools
- type DelegationRecord
- type DeliveryFailure
- type Digest
- type DispatchOutcome
- type DispatchRecord
- type Error
- type ExchangeGrant
- type FindScheduleRequest
- type FindSessionRequest
- type Gateway
- type GatewayAS2
- type GatewayAuthServer
- type GatewayEntry
- type GatewayKind
- type GatewayTokenResult
- type Host
- type IDJAGIssuer
- type IDJAGRecord
- type IDJAGRequest
- type IDJAGResult
- type JWK
- type JWKSet
- type Keys
- type Limits
- type ObservedOutcome
- type OpenKind
- type OpenSessionRequest
- type Option
- func WithAgentIssuerFallbacks(keys ...crypto.PublicKey) Option
- func WithAuthServer(as1 AuthServer) Option
- func WithClock(now func() time.Time) Option
- func WithDeliveryFailures(report func(DeliveryFailure)) Option
- func WithGateway(g Gateway) Option
- func WithIDJAGIssuer(as1 IDJAGIssuer) Option
- func WithRecorder(r Recorder) Option
- func WithoutScheduleGrants() Option
- type OutcomeRecord
- type Owner
- type Provenance
- type Reason
- type Record
- type RecordHeader
- type Recorder
- type Redemption
- type RegisterAgentRequest
- type Registration
- type RegistrationRecord
- type ReplacedGrant
- type ReportCallRequest
- type ReportDelegationRequest
- type ReportMismatch
- type ReportRejectedRecord
- type RevokeScheduleRequest
- type ScheduleConsent
- type ScheduleDigest
- type ScheduleEndCause
- type ScheduleExpiredRecord
- type ScheduleGrantView
- type ScheduleMark
- type ScheduleRevokeCause
- type ScheduleRevokedRecord
- type ScheduleSetup
- type ScheduleSetupRecord
- type ScheduleStatus
- type ScheduleTrigger
- type ServerRefusal
- type Service
- type Session
- type SessionCloseRecord
- type SessionOpenRecord
- type Subject
- type SubjectProvenance
- type Subjects
- type Token
- type TokenExchange
- type TokenExchangeResult
- type ToolList
- type ToolListServer
- type UnverifiedAuthenticator
- type User
- type VerifiedAgent
- type VerifyCredentialForOwnerRequest
- type VerifyCredentialRequest
- type Workload
Constants ¶
const ( // BrokerClientID is the identity broker's OAuth client at AS-1 and AS-2. BrokerClientID = "mecatl" // MaxClientAssertionLifetime is the largest exp - iat of a client // assertion, and the lifetime used when none is configured. MaxClientAssertionLifetime = 60 * time.Second )
const ( // MinLimit is the least value of every Limits setting. MinLimit = time.Second // MaxIDJAGMaxLifetime bounds Limits.IDJAGMaxLifetime: ToolHive's largest // id_jag_max_lifetime. MaxIDJAGMaxLifetime = 720 * time.Hour // MaxScheduleGrantMaxLifetime bounds Limits.ScheduleGrantMaxLifetime: // ToolHive's largest refresh_token_max_lifetime. MaxScheduleGrantMaxLifetime = 720 * time.Hour // MaxIDJAGLifetime bounds Limits.IDJAGLifetime: ToolHive's largest ID-JAG // lifetime. MaxIDJAGLifetime = 5 * time.Minute // MaxAS1RequestTimeout bounds Limits.AS1RequestTimeout, and so how long // session open holds a host session's open lock. MaxAS1RequestTimeout = 30 * time.Second // MaxAS2RequestTimeout bounds Limits.AS2RequestTimeout, and so how long a // gateway call waits for AS-2. MaxAS2RequestTimeout = time.Minute )
Bounds of Limits.
const ( // SourceGlobal is the source of the operator's global definitions. SourceGlobal = "global" // SourceSystem is the source of the built-in definitions each Mecatl // release ships. SourceSystem = "system" // BuiltinMain names the built-in definition of the main agent of a session // started without a named definition: system/main. BuiltinMain = "main" // BuiltinExplorer names the built-in definition of the child agent of a // subagent call that names no definition: system/explorer. BuiltinExplorer = "explorer" // BuiltinBranch names the built-in definition of a parallel branch, which // runs no named definition: system/branch. BuiltinBranch = "branch" // BuiltinMember names the built-in definition of a team member that names // no agent type: system/member. BuiltinMember = "member" )
Definition sources and built-in names. Registrations name them, so they are part of the registration contract, not details of the loader that produces the records.
const ( TypeSessionOpen = "mecatl_session_open" TypeSessionClose = "mecatl_session_close" TypeInstanceRegistered = "mecatl_instance_registered" TypeDelegation = "mecatl_delegation" TypeIDJAG = "mecatl_id_jag" TypeToolDecision = "mecatl_tool_decision" TypeToolDispatch = "mecatl_tool_dispatch" TypeToolOutcome = "mecatl_tool_outcome" TypeToolReportRejected = "mecatl_tool_report_rejected" TypeScheduleSetup = "mecatl_schedule_setup" TypeScheduleRevoked = "mecatl_schedule_revoked" TypeScheduleExpired = "mecatl_schedule_expired" )
Record types, the AuditEvent Type of each record.
const ( // AuditProfile names the profile and its version, in // Metadata.Extra["mecatl.profile"]. AuditProfile = "mecatl-agent-identity/1" ExtraProfile = "mecatl.profile" ExtraProvenance = "mecatl.provenance" ExtraOccurredAt = "mecatl.occurred_at" ExtraClock = "mecatl.clock" ExtraOperationID = "mecatl.operation_id" ExtraAttemptID = "mecatl.attempt_id" ExtraSupersedes = "mecatl.supersedes" ExtraReplica = "mecatl.replica" ExtraDeployment = "mecatl.deployment" ExtraTrustDomain = "mecatl.trust_domain" )
The AuditEvent profile every Mecatl producer records in (audit.md, "AuditEvent profile"): its name and version, and its Metadata.Extra keys. The broker's sink and mecak8s's own recorder both write them.
const ( SubjectUserIssuer = "user_iss" SubjectUserID = "user_id" SubjectOwnerIssuer = "owner_iss" SubjectOwnerID = "owner_id" SubjectUserClientID = "user_client_id" SubjectUserClientIssuer = "user_client_iss" SubjectWorkloadIssuer = "workload_iss" SubjectWorkloadSubject = "workload_sub" SubjectAgentSPIFFEID = "agent_spiffe_id" SubjectAgentActorID = "agent_actor_id" SubjectAgentInstanceRef = "agent_instance_ref" SubjectRunOwnerIssuer = "run_owner_iss" SubjectRunOwnerID = "run_owner_id" )
The Subjects keys of audit.md's AuditEvent profile.
const ( // SubjectGatewayTokenJTI is the accepted gateway token's jti, the // decision's data.gateway_token.jti: one attempt of one call. SubjectGatewayTokenJTI = "gateway_token_jti" // SubjectOperationID is the operation the accepted token is bound to, // the decision's metadata.extra "mecatl.operation_id": the call, across // its attempts. SubjectOperationID = "operation_id" )
The Subjects keys the embedded MCP gateway's events name the accepted gateway token and its call by, which join each event to one decision.
const ( // ScheduleRevokeOwnerRevoked is a revocation without a deletion, as // ScheduleEndOwnerRevoked. ScheduleRevokeOwnerRevoked = ScheduleRevokeCause(ScheduleEndOwnerRevoked) // ScheduleRevokeDeleted is a deletion, or a revocation of a schedule // already deleted, as ScheduleEndDeleted. ScheduleRevokeDeleted = ScheduleRevokeCause(ScheduleEndDeleted) // ScheduleRevokeSetupCancelled means a pending setup was cancelled; it // does not end the schedule's stored grant. ScheduleRevokeSetupCancelled ScheduleRevokeCause = "setup_cancelled" // ScheduleRevokeSetupReplaced means a new setup replaced a pending one; // it does not end the schedule's stored grant. ScheduleRevokeSetupReplaced ScheduleRevokeCause = "setup_replaced" )
const ( MethodToolsCall = "tools/call" MethodToolsList = "tools/list" )
The MCP methods AuthorizeCallRequest.Method names.
const ( MaxListedServers = 64 MaxListedToolsPerServer = 512 MaxListedToolNameBytes = 128 )
MaxListedServers, MaxListedToolsPerServer, and MaxListedToolNameBytes bound a CompleteScheduleSetupRequest's ListedTools, which come from upstream MCP servers and are held for the schedule and recorded at each of its runs' opens, so a record stays small. A request over a bound is refused, never truncated, since a truncated list would narrow what the owner consented to.
const ( // ExchangeGrantType is the RFC 9396 authorization_details type of // ToolHive's exchange grant: a refresh token whose use is fixed when it is // issued. ExchangeGrantType = "https://toolhive.dev/exchange_grant" // TokenTypeIDJAG is the ID-JAG token type, the only output the broker's // grants issue. TokenTypeIDJAG = "urn:ietf:params:oauth:token-type:id-jag" // #nosec G101 -- token type URN, not a credential. // TokenTypeRefreshToken is the RFC 8693 refresh token type, the token a // session-open exchange issues. TokenTypeRefreshToken = "urn:ietf:params:oauth:token-type:refresh_token" // #nosec G101 -- token type URN, not a credential. )
Token types and the authorization_details type of the session-open exchange (design step (3)).
const CallEntryType = "https://toolhive.dev/mcp_tool_call"
CallEntryType is the authorization_details type of a call entry (credentials-and-lifecycle.md, step (8)): ToolHive's MCP call type. AS-1 signs the entry the broker sends into the ID-JAG, AS-2 copies it into the gateway token, and the vMCP accepts that token for the one call it names.
const ComponentBroker = "mecatl-broker"
ComponentBroker is the Component of every record the broker's audit sink writes.
const ComponentMecak8s = "mecak8s"
ComponentMecak8s is mecak8s as a recording component: the Component of its own audit events, and the component ProvenanceReportedByMecak8s names.
const DigestSHA256 = "sha256"
DigestSHA256 is the only digest algorithm this package accepts.
const GatewaySignInTool = "sign_in"
GatewaySignInTool is the name, on each gateway server, of the tool the gateway lists in place of the server's tools while the user has not connected the server's provider. The gateway reserves the name on every server: a server's own tool of that name is not listed or routed.
const MaxClockSkew = 60 * time.Second
MaxClockSkew bounds Config.ClockSkew. A skew extends every expiry the broker checks, an agent credential's and a stored converted access token's, and ends every session that much early, so the bound rejects unit mistakes such as minutes entered for seconds. It is 60s because AS-1's actor validator returns the credential's real exp, and ToolHive answers actor_token_expired only for an exp under 60s in the past: a larger skew lets the broker accept a credential AS-1 then answers with a server error, so the agent never renews it.
const MaxCredentialLifetime = time.Hour
MaxCredentialLifetime bounds Config.CredentialLifetime. Agent credentials are short-lived bearer tokens; the bound limits how long a stolen one stays usable and rejects unit mistakes such as hours entered for minutes. The value is an interim choice: the agent identity design does not set one.
const MaxSegmentBytes = 63
MaxSegmentBytes bounds DefinitionRef.Source and DefinitionRef.Name, the registration cap on a definition category and name (design registration check 6).
const MaxToolCallIDBytes = 256
MaxToolCallIDBytes bounds a tool call ID the broker records, so every recorded ID can be followed.
const TokenTypeJWT = "urn:ietf:params:oauth:token-type:jwt" // #nosec G101 -- token type URN, not a credential.
TokenTypeJWT is the RFC 8693 JWT token type, the type of the agent SVID a per-call ID-JAG exchange sends as its actor token.
Variables ¶
var ( ErrInvalidConfig = errors.New("identitybroker: invalid configuration") ErrInvalidSigner = errors.New("identitybroker: invalid signer") ErrInvalidDefinition = errors.New("identitybroker: invalid definition record") ErrConflictingDefinition = errors.New("identitybroker: conflicting definition records") )
Errors returned by New and DefinitionRecord.Validate. Each returned error wraps exactly one of them, so a transport adapter can map failures with errors.Is.
var ErrMalformedResponse = errors.New("identitybroker: the authorization server's response could not be decoded")
ErrMalformedResponse reports a success response from AS-1 or AS-2 the broker cannot decode. The server may have issued a token the broker cannot read, so session open closes the session, as for a mismatched answer. Errors wrapping it also wrap ErrTransportConfiguration.
var ErrNoResponse = errors.New("identitybroker: no response from the authorization server")
ErrNoResponse reports a token or revocation endpoint request to AS-1 or AS-2 that got no response, such as a dropped connection: the server may or may not have processed it. Callers may retry once, with a new client assertion. At session open the retry resends the same access token: if AS-1 had converted it, the resend is refused with token_used and the client must refresh its access token and open again (design step (3), "Lost response"), which applies to a 502 or 504 there too.
var ErrTransportConfiguration = errors.New("identitybroker: the connection to the authorization server is misconfigured")
ErrTransportConfiguration reports a request to AS-1 or AS-2 that failed because the connection's configuration is wrong, such as a server certificate that does not verify against the configured trust, or because a success response could not be decoded, which points at the wrong or an incompatible server (see ErrMalformedResponse): a configuration fault, not an outage, so it is not retried.
Functions ¶
func ActorIssuer ¶ added in v0.0.53
ActorIssuer is the act.iss naming the agents of trustDomain; changing it renames every agent.
func CheckRegistration ¶ added in v0.0.53
func CheckRegistration(reg Registration) error
CheckRegistration reports whether reg has the form of a registration's answer: its agent is an agent instance's SPIFFE ID, spiffe://<trust domain>/agent/<ag_ identifier>, and its credential's sub names that agent. It reads the credential without verifying it: the broker that issued it verifies it on use. A caller that holds an earlier registration of the same incarnation also checks that reg names the same agent, since the ID carries nothing a caller could predict.
func IsConfigurationFault ¶ added in v0.0.52
IsConfigurationFault reports whether err is a failure the design's error reasons treat as a configuration fault or broker bug (gRPC INTERNAL): ErrTransportConfiguration, or a refusal with invalid_client, unauthorized_client, or invalid_target, or with the reason subject_token_audience, subject_token_source_client, grant_invalid, upstream_subject_missing, sub_id_missing, dpop_not_supported, bound_elapsed, or resource_denied, or any other refusal without a known reason code. A description that does not follow the reason-code convention, such as prose, counts as no reason. A transient refusal (see IsUnavailable) never is. A failed client authentication is always invalid_client. A caller needing a reason-specific outcome, such as an AS-2 invalid_grant with no reason, checks the ServerRefusal first. Session open does: AS-1 refuses an access token a fresh one could replace with subject_token_invalid, which session open reports as subject_invalid; an invalid_request with no reason is a broker bug or configuration fault there too (design step (3)).
func IsUnavailable ¶ added in v0.0.52
IsUnavailable reports whether err is a retryable infrastructure failure (gRPC UNAVAILABLE), not a denial: ErrNoResponse, or a transient refusal.
func ValidToolCallID ¶ added in v0.0.53
ValidToolCallID reports whether id can be recorded as a transcript point: non-empty, valid UTF-8, printable text without spaces, at most MaxToolCallIDBytes long. mecak8s sends no ID it fails, and the decision then marks the point unavailable.
This is a deliberate second copy of session.ValidToolCallID, which the transcript read and mecak8s use. The broker core imports no Mecatl package, so it can become its own service, and it keeps the rule here rather than import it. It does not share isToken with the broker's other fields, so changing those rules leaves this one alone; TestTheBrokerRecordsTheToolCallIDsATranscriptReadFollows pins both copies to the same accepted IDs.
func ValidateGatewayEntries ¶ added in v0.0.53
func ValidateGatewayEntries(entries []GatewayEntry) error
ValidateGatewayEntries checks entries as the broker accepts them: at most one entry, of kind GatewayEmbedded; its issuer, token endpoint, and resource non-empty printable text without spaces; and its servers letters, digits, and single underscores (isGatewayServerName), each listed once. The loader checks the URLs. Errors wrap ErrInvalidConfig.
Shortcut: at most one gateway entry, of kind embedded; removed by #2812 (external gateways, and several gateways).
func ValidateTrustDomain ¶ added in v0.0.53
ValidateTrustDomain applies the SPIFFE-ID trust domain grammar to td, a trust domain name without the spiffe:// scheme: lowercase letters, digits, '.', '-' and '_', at most 255 bytes.
Types ¶
type AgentRef ¶
type AgentRef struct {
Subject string
}
AgentRef refers to a registered agent instance by its canonical subject, its SPIFFE ID, which the caller checks with CheckRegistration. The zero value refers to no agent.
type AuthServer ¶ added in v0.0.52
type AuthServer interface {
Exchange(ctx context.Context, req TokenExchange) (TokenExchangeResult, error)
}
AuthServer is AS-1's token endpoint as session open uses it: the RFC 8693 exchange of the user's access token for a refresh token that issues only ID-JAGs. The adapter authenticates as BrokerClientID with a fresh client assertion on every call and serialises req as it is. A refusal is a *ServerRefusal; a request with no response wraps ErrNoResponse; a misconfigured connection wraps ErrTransportConfiguration; a success response it cannot decode wraps both ErrMalformedResponse and ErrTransportConfiguration. Errors never carry a token.
type Authenticator ¶
Authenticator decides which workload is calling. A failure is an *Error, normally with CodeUnauthenticated or CodePermissionDenied.
type Authorization ¶
type Authorization struct {
// GatewayToken is the token the call is dispatched with, obtained for
// this call alone.
GatewayToken Token
// ExpiresAt is the broker's use-before deadline for GatewayToken: the
// earliest of the ID-JAG's exp, AS-2's expires_in, and the token's own
// exp. The authorization server may keep the token valid longer.
ExpiresAt time.Time
// AttemptID identifies this authorization, so a caller whose token the
// gateway rejects reports it in AuthorizeCallRequest.RejectedAttemptID.
AttemptID string
}
Authorization is an allowed MCP call.
type AuthorizeCallRequest ¶
type AuthorizeCallRequest struct {
SessionID string
// Credential is the acting agent's credential from RegisterAgent. The
// broker identifies the acting agent from it.
Credential Token
// OperationID identifies this call.
OperationID string
// ToolCallID is the ID of the model's tool call this call serves, as
// the acting agent's host session records it. With the host session and
// incarnation in the acting agent's registration, it names the point in
// the transcript where the call was made (audit.md, "Transcript point").
// A tools/call names it when the model gave one that ValidToolCallID
// accepts; otherwise it names none, and the decision marks the point
// unavailable rather than the call being refused. A tools/list carries
// none.
ToolCallID string
// RunID is the run the call belongs to.
RunID string
// DelegationID is the delegation the run acts under; empty for a root
// run.
DelegationID string
// RunOwner is the owner the run acts for.
RunOwner Owner
// Method is MethodToolsCall or MethodToolsList.
Method string
// Server is the gateway backend the call is routed to, such as "github".
Server string
// Tool is the exact tool name the call sends as params.name, such as
// "github.pull_request_read": the server's name, a dot, and the tool's
// name on the server. Set for tools/call only.
Tool string
// ArgumentsSHA256 is the argument hash, 64 lowercase hex characters, as
// credentials-and-lifecycle.md step (8), "The argument hash", defines it:
// the SHA-256 of the RFC 8785 (JCS) serialization of params.arguments as
// sent, or of {} when there are none, not of the raw request bytes. Set
// for tools/call only.
ArgumentsSHA256 string
// RejectedAttemptID, when set, reports that the gateway rejected the token
// of that attempt, so the broker obtains a fresh one. A caller reports an
// attempt at most once, with the attempt's own call fields.
RejectedAttemptID string
}
AuthorizeCallRequest asks whether an agent may make one MCP call.
func (AuthorizeCallRequest) Validate ¶
func (r AuthorizeCallRequest) Validate() error
Validate reports whether r is well formed. The error is an *Error with CodeInvalidArgument.
type BeginScheduleSetupRequest ¶ added in v0.0.53
type BeginScheduleSetupRequest struct {
// ScheduleID is the schedule, which exists already: setup is a step on a
// schedule, apart from creating it.
ScheduleID string
// Owner is the schedule's owner, as the caller verified the request's
// user. The access token's sub_id must equal it, and so must the owner
// the broker recorded for the schedule, if any.
Owner Owner
// AccessToken is the owner's freshly refreshed AS-1 access token, which
// the broker converts into the schedule grant. AS-1 converts each token
// once, so it is spent whether or not the setup completes.
AccessToken Token
// Horizon is when the owner asks the grant to end. AS-1 may cap it at its
// maximum for schedule grants; ScheduleSetup.Horizon is the horizon
// granted.
Horizon time.Time
// Definition is the definition the schedule runs, exactly one the broker
// loaded, such as the built-in system/main at its loaded revision.
Definition DefinitionRef
// Digest is the schedule's digest as the owner sets it up. Completing
// the setup stores it with the grant, and each run's open must carry it
// (OpenSessionRequest.Digest), so a schedule changed since, during this
// setup included, needs setup again.
Digest ScheduleDigest
}
BeginScheduleSetupRequest begins setting up, or renewing, a schedule's grant while its owner is present (credentials-and-lifecycle.md, "Schedule setup").
func (BeginScheduleSetupRequest) Validate ¶ added in v0.0.53
func (r BeginScheduleSetupRequest) Validate() error
Validate reports whether r is well formed. The error is an *Error with CodeInvalidArgument.
type Broker ¶
type Broker struct {
// contains filtered or unexported fields
}
Broker is the identity broker core. Its startup state is immutable after New, except the gateway's AS-2: New binds a non-zero Gateway.AS2, BindGatewayAS2 binds one while none is bound, and its unbind removes it, so binding again after an unbind works. Its broker sessions are guarded by a mutex. Its methods are safe for concurrent use.
func New ¶
func New(config Config, definitions []DefinitionRecord, signer crypto.Signer, opts ...Option) (*Broker, error)
New validates its inputs and returns a ready Broker, or an error wrapping one of the package's sentinel errors. Inputs are copied before validation, so later caller mutations cannot affect the broker. Records that repeat a reference with identical provenance collapse to one; records that repeat a reference with different provenance are rejected. An empty definition set is valid. New rejects the whole set if any record is invalid; a loader that skips bad definitions filters them first with DefinitionRecord.Validate.
The signer must have an ECDSA P-256 public key, the ES256 algorithm that JWT-SVID permits. A raw *ecdsa.PrivateKey is copied; any other signer, such as a KMS handle, is retained as supplied.
Options add optional collaborators, such as WithAuthServer, and are validated after they are applied.
func (*Broker) AuthorizeCall ¶
func (b *Broker) AuthorizeCall(ctx context.Context, workload Workload, req AuthorizeCallRequest) (Authorization, error)
AuthorizeCall implements Core, in the order Service.AuthorizeCall documents. An invalid request is recorded as refused, naming only the calling workload and, when the broker knows it as the workload's scheduled session, the session it names and that session's schedule, as are refusals after the session lookup.
func (*Broker) BeginScheduleSetup ¶ added in v0.0.53
func (b *Broker) BeginScheduleSetup(ctx context.Context, workload Workload, req BeginScheduleSetupRequest) (ScheduleSetup, error)
BeginScheduleSetup implements Core. With WithoutScheduleGrants it refuses every setup with CodeFailedPrecondition. Otherwise it runs session open's broker check 1 against req.Owner, refuses a schedule recorded for another owner and an ended one, and refuses a definition the broker did not load, all without calling AS-1, so the token is not spent; it then converts the token at AS-1 as session open does, for a grant that issues only refresh tokens and expires at req.Horizon or AS-1's cap, and checks the echo the same way. Its result is held, with req.Digest, as the schedule's pending setup, which replaces an earlier one, recording that one's drop (dropSetup) and closing its listing session, and leaves a stored grant in use. A schedule that changed while AS-1 converted the token needs no check here: its digest differs from req.Digest, so its runs are refused once the setup completes.
A refusal is recorded, not waited for; a begun setup is recorded when it completes.
Shortcut: a schedule grant the broker discards, from a mismatched echo, a setup that is replaced or cancelled, or one that lapses, is not revoked at AS-1; removed by #2568 (refresh-token revocation).
func (*Broker) BindGatewayAS2 ¶ added in v0.0.52
func (b *Broker) BindGatewayAS2(as2 GatewayAS2) (unbind func(), err error)
BindGatewayAS2 binds the configured gateway's AS-2, which AuthorizeCall needs to redeem ID-JAGs; until it is bound, a call that passes the checks before a grant fails with CodeUnavailable. It returns an error wrapping ErrInvalidConfig when no gateway is configured, AS-2 is already bound, or as2 is incomplete or names another issuer or resource than the gateway's.
The returned unbind is idempotent and leaves a later binding alone. It returns once the calls using this binding have finished; calls after it starts find AS-2 unbound. It must not be called from as2's AuthServer or the broker's IDJAGIssuer, as it would wait for its own call.
Shortcut: AS-2 bound late, leaving an UNAVAILABLE window; removed by #2559 (AS-2 reached over the network as a configured gateway entry).
func (*Broker) CancelScheduleSetup ¶ added in v0.0.53
func (b *Broker) CancelScheduleSetup(_ context.Context, workload Workload, req CancelScheduleSetupRequest) error
CancelScheduleSetup implements Core: it drops the schedule's pending setup when it is req.SetupID, recording the drop, not waiting for the record, and closing its listing session, and leaves the schedule as it is otherwise, its stored grant included. Cancelling a setup that is not pending succeeds.
func (*Broker) Close ¶ added in v0.0.53
Close sends the records the broker has queued, of closes and refusals, until ctx ends, and reports each it could not send by then as a delivery failure, returning an error that counts them. A record queued after Close is reported as dropped. Call it at shutdown, once calls have stopped; an end-to-end test calls it to wait for every record.
Shortcut: records still queued at Close are reported, not kept for a later delivery; removed by #2848 (lossless delivery).
func (*Broker) CloseSession ¶
CloseSession implements Core. A call already in progress is refused with the closing reason at its next session check and gets no gateway token, even if AS-2 has already issued one. CloseSession discards the session's refresh token; an open converting a token for an existing session meanwhile discards the new one. A new session is not in the table until its open is recorded, so a close by session ID cannot reach it; a close of its host session's incarnation closes it, and the open then fails and stores nothing. Neither waits for an open in progress. A close of a host session closes only the incarnation it names, and refuses opens of that incarnation for hostClosedLifetime (closeHostLocked).
Shortcut: a discarded refresh token is not revoked; removed by #2568 (refresh-token revocation).
func (*Broker) CompleteScheduleSetup ¶ added in v0.0.53
func (b *Broker) CompleteScheduleSetup(ctx context.Context, workload Workload, req CompleteScheduleSetupRequest) (CompletedScheduleSetup, error)
CompleteScheduleSetup implements Core. It refuses, without changing the schedule, an owner other than the schedule's recorded one (ReasonSessionOwned), an ended schedule (its reason), and a setup that is not pending; then it takes the schedule's ceiling and tool list from the definition's ceiling and the tools listed (scheduleTools) and records the setup, or a renewal when the schedule holds a stored grant, waiting for the record to be accepted before storing anything (audit.md, "Delivery protection and reconciliation").
A record not accepted drops the pending setup, whose grant converted the owner's access token, and leaves a stored grant in use; it fails with CodeUnauthenticated and ReasonRecordNotAccepted, as a session open that converted its token does, so the client refreshes the token before setting up again. A setup replaced, cancelled, or ended while its record was sent is refused too, superseding the record. Otherwise the pending grant becomes the schedule's stored grant, replacing any earlier one: runs already open keep their own refresh tokens, and new runs use the new grant. The grant a renewal replaces is not revoked, as that would stop the runs it started (credentials-and-lifecycle.md, "Scheduled-run session open"); it runs out at its horizon. Once the record is sent, the setup's listing session is closed, whether or not the grant is stored.
Shortcut: a schedule grant the broker discards because its setup record was not accepted is not revoked at AS-1; removed by #2568 (refresh-token revocation).
func (*Broker) Definition ¶
func (b *Broker) Definition(ref DefinitionRef) (DefinitionRecord, bool)
Definition returns a copy of the loaded record for ref, and whether one exists. Mutating the returned record does not affect the broker.
func (*Broker) FindSchedule ¶ added in v0.0.53
func (b *Broker) FindSchedule(_ context.Context, workload Workload, req FindScheduleRequest) (ScheduleStatus, error)
FindSchedule implements Core.
func (*Broker) FindSession ¶
func (b *Broker) FindSession(ctx context.Context, workload Workload, req FindSessionRequest) (Session, bool, error)
FindSession implements Core.
func (*Broker) OpenSession ¶
func (b *Broker) OpenSession(ctx context.Context, workload Workload, req OpenSessionRequest) (Session, error)
OpenSession implements Core. Opens of one host session run one at a time, so concurrent opens for it return the same broker session.
With an AuthServer configured, an open whose request carries an access token converts it into the session's refresh token, as convert describes. An open without one, or without an AuthServer, only pairs the session with the reported owner.
Every open is recorded (credentials-and-lifecycle.md step (3), "Evidence"). A successful open returns only once its record is accepted. Otherwise it changes nothing: a session it created is closed, a refresh token the session held stays, a refresh token it got is discarded, and the broker still remembers the source jti it converted. It then fails with ReasonRecordNotAccepted: with CodeUnauthenticated when it converted the request's token, which is spent, and CodeUnavailable otherwise. A refused open is returned at once, its record queued, and never leaves a session it created open.
An open naming a schedule opens the session from the schedule's grant instead (openSchedule). A run's open whose record is not accepted is tried once more, as after a lost response, and then fails with CodeUnavailable and ReasonRecordNotAccepted, so the run does not start.
func (*Broker) RegisterAgent ¶
func (b *Broker) RegisterAgent(ctx context.Context, workload Workload, req RegisterAgentRequest) (Registration, error)
RegisterAgent implements Core. It checks the session, the owner, the root host session or the parent and its host session, and the definition or an earlier registration of the instance, issues the credential, records the registration, and only then admits the instance to the session, so a failure changes nothing. A new instance's definition must be one the broker loaded; an instance registered before keeps the definition it registered with, whatever the broker loaded since.
The credential is signed outside any lock. Then, with registrations of the incarnation serialized, the checks run again, the registration is recorded, and the instance is admitted, so the record and the admission act on the same instance. A registration whose record is not accepted fails with ReasonRecordNotAccepted and admits nothing; mecak8s does not retry it, so the helper does not run. A refused registration is recorded and returned whether or not its record is accepted. A registration undone after its success record was sent, because the record was not accepted or the session closed meanwhile, is recorded again as refused, superseding that record, so the records show the instance was not admitted.
Shortcut: a definition the broker did not load is refused, not accepted as reported by mecak8s, and there is no root eligibility or nesting check; removed by #2551.
func (*Broker) ReportCall ¶ added in v0.0.53
ReportCall implements Core, as Service.ReportCall documents. Every report is recorded, unless it repeats one the broker still remembers recording; none is waited for.
func (*Broker) ReportDelegation ¶ added in v0.0.53
func (b *Broker) ReportDelegation(ctx context.Context, workload Workload, req ReportDelegationRequest) error
ReportDelegation implements Core, with the checks of the design's "Delegation report" in order. An accepted report records the delegation and the receiving run, bound to the receiving agent and its owner, and records a delegating root run the broker has not seen yet.
Every report but an identical repeat of an accepted one is recorded as a delegation lineage event (audit.md, "Lineage"). Reports to one broker session run one at a time, so the check, the record, and the store act on the same state. An accepted report is stored only once its record is accepted; otherwise it fails with ReasonRecordNotAccepted and stores nothing, and mecak8s does not report it again, so the helper does not run. A refused report is returned whether or not its record is accepted. A report undone after its success record was sent, because the record was not accepted or the session closed meanwhile, is recorded again as refused, superseding that record.
func (*Broker) RevokeSchedule ¶ added in v0.0.53
func (b *Broker) RevokeSchedule(_ context.Context, workload Workload, req RevokeScheduleRequest) error
RevokeSchedule implements Core: it drops the schedule's stored grant and pending setup, closing the pending setup's listing session, and marks the schedule ended for a deletion, or revoked otherwise, keeping its recorded owner, so its next run fails with ReasonSetupRequired until a setup completes. Runs already open keep the refresh tokens they hold. Revoking a schedule the broker holds nothing for succeeds and marks it all the same. The revocation is recorded and, as a close, takes effect whether or not its record is accepted.
Shortcut: deleting or revoking a schedule drops its grants at the broker but does not revoke them at AS-1, and signing out everywhere does not end them; removed by #2568.
func (*Broker) VerifyCredential ¶
func (b *Broker) VerifyCredential(_ context.Context, req VerifyCredentialRequest) (VerifiedAgent, error)
VerifyCredential implements CredentialVerifier. After the credential's own checks (see credentialIssuer.verify), its subject must be a registered instance, and that instance must be registered to the request's session, and that session must be open, so closing a session ends its credentials' use at once rather than at their expiry. Only a credential issued since the instance moved to this session verifies, so reopening a session does not revive credentials issued before it closed. Per-instance subjects are what bind a credential to one session, with no session claim. It does not check which workload opened the session; the broker's per-operation checks do.
func (*Broker) VerifyCredentialForOwner ¶ added in v0.0.52
func (b *Broker) VerifyCredentialForOwner(_ context.Context, req VerifyCredentialForOwnerRequest) (VerifiedAgent, error)
VerifyCredentialForOwner implements CredentialVerifier. After the credential's own checks, its subject must be a registered instance whose present session is open and owned by req.Owner, and the credential must have been issued since the instance moved to that session, so a credential from before a session closed does not verify once the instance registers into the session that replaces it. The owner compared is the session's Owner, which its registrations are checked against, not its verified owner: the broker's per-operation checks put the agent in the session whose refresh token AS-1 exchanges, and that session's verified owner equals its Owner. Every refusal after the credential's own checks has the same detail, so an error passed on whole tells AS-1 nothing about the session's state.
type CallEntryCheck ¶ added in v0.0.53
type CallEntryCheck string
CallEntryCheck is the result of the broker's output check (step (8a)): whether AS-2's token response carried the call entry the broker sent.
const ( // CallEntryEqual: the response's authorization_details equals the entry // sent, as decoded JSON values. CallEntryEqual CallEntryCheck = "equal" // CallEntryAbsent: the response has no authorization_details member, or // it is null. CallEntryAbsent CallEntryCheck = "absent" // CallEntryDiffers: the response's authorization_details is not the // entry sent: another entry, another shape, an extra entry, or a value // that is not valid JSON without repeated member names. CallEntryDiffers CallEntryCheck = "differs" )
The output check's results.
type CallReport ¶ added in v0.0.53
type CallReport struct {
Workload Workload
SessionID string
// ScheduleMark is the session's, when the broker knows the session.
ScheduleMark
OperationID string
AttemptID string
// DecisionRecord is the AuditID of the decision that issued the attempt
// for this operation, DecisionSubjects that decision's subjects, and
// CallTarget the call it decided; all empty when the report could not be
// joined to it (Mismatch is MismatchAttemptUnknown or MismatchOperation).
DecisionRecord string
DecisionSubjects Subjects
CallTarget
// Owner is the broker session's owner, as mecak8s reported it, for a
// report not joined to a decision; zero when the session is unknown.
Owner Owner
// Mismatch is empty for a report joined to its decision as the first
// report of its attempt.
Mismatch ReportMismatch
// Cause is the client's fixed code for why the attempt was not sent or
// was refused; empty when it gave none.
Cause string
// ReportProvenance marks the reported facts, the dispatch, outcome, and
// cause. It is always reported by mecak8s.
ReportProvenance SubjectProvenance
}
CallReport is what the broker records of one call report. The records' RecordHeader.At is when the broker received the report, not when the client observed what it reports, so it can be later than the gateway's record of the same call.
type CallTarget ¶ added in v0.0.53
type CallTarget struct {
Method string
Server string
Tool string
RunID string
// RegistrationRecord is the AuditID of the acting agent's registration,
// and DelegationRecord that of the run's delegation; DelegationRecord is
// empty for a root run.
RegistrationRecord string
DelegationRecord string
}
CallTarget is the call a joined report concerns, as the decision that issued its attempt recorded it: its target (Method, Server, Tool), its run, and its lineage references (audit.md, "AuditEvent profile").
type CancelScheduleSetupRequest ¶ added in v0.0.53
CancelScheduleSetupRequest cancels a setup begun and not completed.
func (CancelScheduleSetupRequest) Validate ¶ added in v0.0.53
func (r CancelScheduleSetupRequest) Validate() error
Validate reports whether r is well formed. The error is an *Error with CodeInvalidArgument.
type Ceiling ¶ added in v0.0.53
type Ceiling struct {
// contains filtered or unexported fields
}
Ceiling is the limit on an agent's MCP calls: the servers it may call and, for each, the tools on that server it may call. The broker checks each gateway call against it (design step (6), check 7), and the harness keeps an agent's catalogue to it (DefinitionTools). A server is granted in one of two forms, as a definition grants it: whole, minus the tools it excludes by name, when the definition's tools list names no MCP tool; or only the tools it names, minus those it excludes, when it names some. The first form needs no server's tool list, which only a signed-in user can list and which can differ per user; the second allows no tool the server adds or renames later.
A Ceiling is immutable once made, so it can be shared and compared. The zero Ceiling allows no call.
func NewCeiling ¶ added in v0.0.53
func NewCeiling(servers ...CeilingServer) Ceiling
NewCeiling returns the ceiling granting each of servers the tools it allows. A server listed twice is granted only what every one of its entries allows, and a server with a list of tools all of which are excluded is not granted. Blank server names are ignored and server names are trimmed, as the harness trims a definition's server references; tool names are kept exactly, as the harness matches them exactly, and an empty one is ignored.
func (Ceiling) Allows ¶ added in v0.0.53
Allows reports whether c allows a call of tool, by its name on server.
func (Ceiling) GrantsServer ¶ added in v0.0.53
GrantsServer reports whether c grants server at all: whether it allows a listing of the server, and any of its tools.
func (Ceiling) Servers ¶ added in v0.0.53
func (c Ceiling) Servers() []CeilingServer
Servers returns the servers c grants, sorted, each with its tools and excluded tools sorted. A server granted a list of tools has no excluded tools: they are already left out of the list; its sign-in tool, when the list allows it, is SignInTool, apart from the list.
func (Ceiling) String ¶ added in v0.0.53
String is c in a canonical form for records: each granted server, sorted, followed by the only tools it allows or by the tools it excludes, as in "calendar; github only pull_request_get,pull_request_list; jira except delete_issue". A tool name other than letters, digits, '_', '-', and '.' is quoted as a Go string, so a name holding a separator cannot be read as two. Server names are gateway server names, which hold none. It is "none" for a ceiling that grants nothing.
type CeilingServer ¶ added in v0.0.53
type CeilingServer struct {
Server string
OnlyTools []string
ExceptTools []string
SignInTool string
}
CeilingServer is one server a ceiling grants and the tools on it the ceiling allows, by their name on the server, such as "merge_pr" for the tool the gateway names "github.merge_pr": with OnlyTools empty, every tool but ExceptTools; otherwise each of OnlyTools but ExceptTools, and SignInTool unless ExceptTools names it. A non-empty OnlyTools that names no tool other than the empty name or SignInTool allows none, sign-in tool included. SignInTool is ignored without OnlyTools.
type ClientAssertionSigner ¶ added in v0.0.52
type ClientAssertionSigner struct {
// contains filtered or unexported fields
}
ClientAssertionSigner mints the private_key_jwt client assertions (RFC 7523) the broker authenticates with as BrokerClientID at every token and revocation endpoint request. Its key is the broker client key, separate from the agent issuer's. It is safe for concurrent use.
func NewClientAssertionSigner ¶ added in v0.0.52
func NewClientAssertionSigner(signer crypto.Signer, lifetime time.Duration) (*ClientAssertionSigner, error)
NewClientAssertionSigner returns a signer for assertions with the given lifetime: zero selects MaxClientAssertionLifetime, and a lifetime shorter than a second or longer than MaxClientAssertionLifetime is refused. The signer must have an ECDSA P-256 public key; a raw *ecdsa.PrivateKey is copied, any other signer, such as a KMS handle, is retained as supplied. Errors wrap ErrInvalidSigner or ErrInvalidConfig.
func (*ClientAssertionSigner) ClientAssertion ¶ added in v0.0.52
ClientAssertion returns a fresh assertion for the authorization server whose issuer identifier is audience: header typ client-authentication+jwt, alg ES256, and the key's kid; claims iss and sub BrokerClientID, aud audience as a single string, iat now, exp the lifetime after iat, and a random jti. Each call yields a new jti, so an assertion is used once.
func (*ClientAssertionSigner) JWKS ¶ added in v0.0.52
func (s *ClientAssertionSigner) JWKS() JWKSet
JWKS returns the public key set authorization servers register for BrokerClientID, inline, as ToolHive accepts no jwks_uri.
type CloseCause ¶ added in v0.0.53
type CloseCause string
CloseCause is why a broker session closed.
const ( // CloseRequested means mecak8s closed the session. CloseRequested CloseCause = "requested" // CloseHardExpiry means a lookup found the session past its hard expiry. CloseHardExpiry CloseCause = "hard_expiry" // CloseMismatchedAnswer means AS-1's answer at session open did not match the // request or could not be decoded. CloseMismatchedAnswer CloseCause = "mismatched_answer" // CloseGrantLost means AS-1 reported the session's refresh token revoked and // the session held no newer one. CloseGrantLost CloseCause = "grant_lost" // CloseOpenRefused means the open that created the session was refused, // or undone because its record was not accepted, so the session does not // stay open. The close refers to the refusal's record, which is queued // before it. CloseOpenRefused CloseCause = "open_refused" )
type CloseSessionRequest ¶
type CloseSessionRequest struct {
SessionID string
// RootHostSessionID closes an incarnation of a root host session instead,
// when the host session is deleted or its scheduled run ends: its open
// broker session of RootHostIncarnation, if any, and the one an open of
// that incarnation in progress is creating, which that open then fails
// and stores nothing for. For a while afterwards, any other open of
// RootHostIncarnation fails with ReasonSessionClosed before converting
// anything, unless an earlier check refuses it first, so an open that
// started before the close gives the host session no new broker session;
// on another replica, or once that while has passed, it can. A broker
// session of another incarnation, as when the host session is created
// again under its ID, is neither closed nor refused, and keeps the host
// session's delegation history, which is otherwise forgotten. Closing a
// host session with no broker session succeeds.
RootHostSessionID string
// RootHostIncarnation is the closed host session's incarnation, required
// with RootHostSessionID and empty otherwise.
RootHostIncarnation string
// Reason is the closing reason later calls on the session fail with.
// ReasonSessionClosed is the only closing reason Mecatl supplies today.
Reason Reason
}
CloseSessionRequest closes a broker session, named by exactly one of SessionID and RootHostSessionID.
func (CloseSessionRequest) Validate ¶
func (r CloseSessionRequest) Validate() error
Validate reports whether r is well formed. The error is an *Error with CodeInvalidArgument.
type Code ¶
type Code string
Code classifies a Service error. The values mirror the gRPC status codes the agent identity design assigns, without importing gRPC.
const ( CodeUnauthenticated Code = "UNAUTHENTICATED" CodePermissionDenied Code = "PERMISSION_DENIED" CodeInvalidArgument Code = "INVALID_ARGUMENT" CodeFailedPrecondition Code = "FAILED_PRECONDITION" CodeAlreadyExists Code = "ALREADY_EXISTS" CodeAborted Code = "ABORTED" CodeInternal Code = "INTERNAL" )
Codes a Service error can carry.
type CompleteScheduleSetupRequest ¶ added in v0.0.53
type CompleteScheduleSetupRequest struct {
ScheduleID string
SetupID string
// Owner is the schedule's owner, as the caller verified the request's
// user; it must be the owner the broker recorded for the schedule.
Owner Owner
// ListedTools are the real tools each gateway server listed in the
// setup's listing session, by server, each by its name on the server,
// as a ceiling's exclusions name tools. A server that listed only its
// sign-in tool, or whose listing AS-2 refused with subject_unknown or
// consent_required, lists none, and is left out of the schedule's
// ceiling.
ListedTools map[string][]string
}
CompleteScheduleSetupRequest completes a setup or renewal begun, once its listing session has listed the definition's gateway servers (credentials-and-lifecycle.md, "Schedule setup", "Connections").
func (CompleteScheduleSetupRequest) Validate ¶ added in v0.0.53
func (r CompleteScheduleSetupRequest) Validate() error
Validate reports whether r is well formed. The error is an *Error with CodeInvalidArgument.
type CompletedScheduleSetup ¶ added in v0.0.53
type CompletedScheduleSetup struct {
ScheduleID string
ScheduleGrantView
// LeftOut are the servers of the definition's ceiling that listed no
// real tools at setup, sorted.
LeftOut []string
// Renewal reports that the grant replaced one the schedule held.
Renewal bool
}
CompletedScheduleSetup is a setup or renewal completed: the grant runs now use, and the servers left out of its ceiling, which the owner is shown and can connect before renewing.
type Config ¶
type Config struct {
// TrustDomain is the SPIFFE trust domain name for agent identities, such as
// "agents.example.com", without the spiffe:// scheme.
TrustDomain string
// Audience is the single audience every agent credential names: the
// broker's, such as "https://broker.example.com". JWT-SVID recommends one
// audience per token, and the broker's verifiers reject more than one.
Audience string
// CredentialLifetime is the validity period of an agent credential. It must
// be positive and at most MaxCredentialLifetime.
CredentialLifetime time.Duration
// ClockSkew is how far the broker's clock may differ from another
// party's, from zero to MaxClockSkew. A verifier accepts an agent
// credential until its exp plus the skew; the broker counts a session's
// hard expiry as reached one skew early, so it never presents a grant AS-1
// may already have expired; and it remembers a converted access token
// until its exp plus the skew, which must cover the skew AS-1 allows on
// an access token's exp (none: AS-1 refuses a token once its exp passes).
ClockSkew time.Duration
}
Config is the operator-supplied identity configuration. The caller resolves it from whatever configuration source it uses; New validates it. Config holds only immutable values, so New's copy is independent of the caller's.
type Core ¶
type Core interface {
OpenSession(ctx context.Context, workload Workload, req OpenSessionRequest) (Session, error)
FindSession(ctx context.Context, workload Workload, req FindSessionRequest) (Session, bool, error)
CloseSession(ctx context.Context, workload Workload, req CloseSessionRequest) error
RegisterAgent(ctx context.Context, workload Workload, req RegisterAgentRequest) (Registration, error)
AuthorizeCall(ctx context.Context, workload Workload, req AuthorizeCallRequest) (Authorization, error)
ReportDelegation(ctx context.Context, workload Workload, req ReportDelegationRequest) error
ReportCall(ctx context.Context, workload Workload, req ReportCallRequest) error
BeginScheduleSetup(ctx context.Context, workload Workload, req BeginScheduleSetupRequest) (ScheduleSetup, error)
CompleteScheduleSetup(ctx context.Context, workload Workload, req CompleteScheduleSetupRequest) (CompletedScheduleSetup, error)
CancelScheduleSetup(ctx context.Context, workload Workload, req CancelScheduleSetupRequest) error
RevokeSchedule(ctx context.Context, workload Workload, req RevokeScheduleRequest) error
FindSchedule(ctx context.Context, workload Workload, req FindScheduleRequest) (ScheduleStatus, error)
}
Core is the broker side of the contract: Service's calls, each with the workload the authenticator determined. Implementations provide the behavior documented on Service, and also:
- A workload that fails Validate is refused with CodeUnauthenticated, before any other check.
- A broker session is bound to the whole Workload that opened it, Verified included, so a verified and an unverified workload with the same name are different workloads. So is a schedule to the Workload that set it up: another workload's schedule of the same ID is another schedule.
- Another workload cannot tell another workload's broker session from none: closing, registering into, calling through, or reporting a delegation into it fails exactly as for an unknown session ID (CodePermissionDenied, before any closing reason), and FindSession reports none open. Opening its host session is refused with CodePermissionDenied.
- AuthorizeCall checks the workload, then the request, neither recorded; then the session, where an unknown session is not recorded and a closed one is; then a rejection report, the session's grant, the credential, the run, and the server, in the order documented on Service; then it exchanges the session's grant for an ID-JAG, records it, and redeems it for the gateway token. Every refusal after the session lookup is recorded with the configured Recorder, and is returned whether or not the record is accepted; a success is returned only once recorded.
type CredentialRef ¶ added in v0.0.52
CredentialRef names a credential by its issuer and ID (iss, jti), never by its value.
type CredentialVerifier ¶
type CredentialVerifier interface {
// VerifyCredential checks an agent credential for use in a broker
// session: the design's credential checks, in order, then that the agent
// is registered to that session, the credential was issued since the
// agent moved there, and the session is open. It returns the agent, its
// ag_ identifier, and the credential's expiry. A malformed request fails
// with CodeInvalidArgument; an expired credential with
// CodeUnauthenticated and ReasonSVIDExpired; a closed session with its
// closing reason, such as ReasonSessionClosed; every other failure with
// CodePermissionDenied and ReasonDenied.
VerifyCredential(ctx context.Context, req VerifyCredentialRequest) (VerifiedAgent, error)
// VerifyCredentialForOwner checks an agent credential for use under a
// grant of req.Owner, as AS-1 does before issuing an ID-JAG: the design's
// credential checks, in order, then that the agent's present broker
// session is open and owned by req.Owner, and the credential was issued
// since the agent moved there. Which of the owner's sessions the call is
// for is not checked here; the broker's per-operation checks do that. It
// returns what VerifyCredential does. It refuses only with
// CodeUnauthenticated and ReasonSVIDExpired for an expired credential, and
// CodePermissionDenied and ReasonDenied for anything else, a malformed
// request and a closed session included, so no closing reason reaches
// AS-1. Any other error means the check could not be made, which AS-1
// treats as retryable.
VerifyCredentialForOwner(ctx context.Context, req VerifyCredentialForOwnerRequest) (VerifiedAgent, error)
}
CredentialVerifier checks agent credentials inside the broker, in two forms: one keyed by broker session, for the broker's own per-operation checks, and one keyed by owner, for AS-1's actor-token validator. Its callers run in process with the broker, so it takes no workload, and Mecatl never calls it. It is apart from Core so that a transport serving Core cannot publish an unauthenticated credential check by accident; AS-1's wiring takes a CredentialVerifier, never a Core.
type DecisionOutcome ¶ added in v0.0.52
type DecisionOutcome string
DecisionOutcome is a record's outcome: how an AuthorizeCall or another event the broker records ended.
const ( OutcomeSuccess DecisionOutcome = "success" OutcomeDenied DecisionOutcome = "denied" OutcomeError DecisionOutcome = "error" OutcomeFailure DecisionOutcome = "failure" OutcomeUnknown DecisionOutcome = "unknown" )
Outcomes: success when the event took effect, error for a CodeInternal or CodeUnavailable failure or a record not accepted, and denied for any other refusal (audit.md, "AuditEvent profile"). A refusal that supersedes an earlier record therefore has error when that record was not accepted, and denied when a close undid its event. A reported dispatch and observed outcome use failure and unknown too, as their fixed sets allow (DispatchOutcome and ObservedOutcome, whose values are these strings).
type DecisionRecord ¶ added in v0.0.52
type DecisionRecord struct {
RecordHeader
SessionID string
ScheduleMark
Workload Workload
// Owner is the broker session's verified owner, or the owner mecak8s
// reported when the session has none; OwnerVerified says which.
Owner Owner
// OwnerVerified is true when Owner is the owner the broker verified at
// session open, and false when it is only what mecak8s reported
// (audit.md, "verified" or "reported:<component>").
OwnerVerified bool
// UserRecord is the AuditID of the record that verified the session's
// user, an open or, in a session opened from a schedule, the schedule's
// setup or renewal record, and User that user; empty when none did. The
// broker sets both with OwnerVerified, and Subjects marks the owner by
// UserRecord: taken from that record.
UserRecord string
User User
// Agent and AgentID are zero when the credential did not verify.
Agent AgentRef
AgentID string
// AgentInstance is the acting agent's incarnation, as mecak8s reported
// it at registration, and RegistrationRecord the AuditID of its latest
// accepted registration; empty before the run checks.
AgentInstance string
RegistrationRecord string
RunID string
DelegationID string
// DelegationRecord is the AuditID of the delegation record of
// DelegationID; empty for a root run or a refusal before the run checks
// passed.
DelegationRecord string
RunOwner Owner
OperationID string
AttemptID string
RejectedAttemptID string
// ToolCallID is the tool call mecak8s reported the call serves: with
// the registration's host session and incarnation, the transcript point.
ToolCallID string
Method string
Server string
Tool string
ArgumentsSHA256 string
// Ceiling is the acting agent's effective ceiling the call was checked
// against (check 7), in Ceiling.String's form; empty when the call was
// refused before that check.
Ceiling string
IDJAG CredentialRef
// GatewayToken names the gateway token. GatewayTokenUnreferenced reports
// an issued token that is not a JWT, so it has no (iss, jti) reference;
// it does not mean no token was issued.
GatewayToken CredentialRef
GatewayTokenUnreferenced bool
// CallEntryCheck is the result of the output check on the gateway
// token's response (step (8a)); empty when no token was issued.
CallEntryCheck CallEntryCheck
}
DecisionRecord records one AuthorizeCall decision.
func (*DecisionRecord) Header ¶ added in v0.0.53
func (r *DecisionRecord) Header() RecordHeader
Header implements Record.
func (*DecisionRecord) Subjects ¶ added in v0.0.53
func (r *DecisionRecord) Subjects() Subjects
Subjects implements Record. The agent's identity is verified once its credential verified; which instance it is, mecak8s reported.
type DefinitionRecord ¶
type DefinitionRecord struct {
Ref DefinitionRef
Provenance Provenance
// Ceiling is the definition's limit on gateway calls, resolved by the
// loader from its MCP servers, the MCP tools it names, and the tools it
// excludes, against the gateway's servers (DefinitionTools). An
// instance's effective ceiling is this one, narrowed by its parent's at
// registration. The zero Ceiling allows no call.
Ceiling Ceiling
}
DefinitionRecord is one loaded definition as the identity core sees it: the reference, its provenance, and the ceiling the loader resolved for it. It deliberately carries no instructions or execution settings.
func (DefinitionRecord) Validate ¶
func (r DefinitionRecord) Validate() error
Validate reports whether r is a well-formed definition record, applying the same rules as New. The returned error wraps ErrInvalidDefinition. A loader that skips bad definitions, rather than failing startup, uses it to filter records before calling New.
type DefinitionRef ¶
type DefinitionRef struct {
// Source identifies where the definition came from, such as "global" for
// operator-loaded definitions or "system" for built-ins: the definition
// category. Agent SPIFFE IDs do not carry it.
Source string
// Name is the definition name within the source, such as "code-reviewer".
Name string
// Revision is the source's own revision identifier, such as a Git commit or
// an object revision. It is opaque to the broker and is not a content digest.
Revision string
}
DefinitionRef identifies one agent definition: the configured source it was loaded from, its name within that source, and the selected source revision. Two references are equal only when all three fields are byte-identical, so the same name from different sources, or at different revisions, names different definitions. DefinitionRef is comparable and is the snapshot key.
type DefinitionTools ¶ added in v0.0.53
type DefinitionTools struct {
Servers []string
Tools []string
DisallowedTools []string
SignInTool string
}
DefinitionTools is what an agent definition says about its MCP tools, with tool names as the harness's catalogue names them, mcp__<server>__<tool>: Servers, the servers its mcpServers names by reference; Tools, its tools list; and DisallowedTools. SignInTool is the name the servers reserve for their sign-in tool, GatewaySignInTool for gateway servers, or empty for servers that reserve none.
It is the one rule both the broker's definition loader and the harness apply: the gateway tools the harness offers an agent are the tools the broker allows it, and the harness limits a definition's other MCP servers the same way.
func (DefinitionTools) Ceiling ¶ added in v0.0.53
func (d DefinitionTools) Ceiling() Ceiling
Ceiling resolves d. When d.Tools names no MCP tool, each of d.Servers is granted every tool, minus each tool d.DisallowedTools names on it. When d.Tools names any MCP tool, it lists the MCP tools d may call, as a Claude Code definition's tools list does: each of d.Servers is granted only the tools d.Tools names on it, minus those d.DisallowedTools names, and a server none of whose tools are named, or whose named tools are all excluded, is not granted. A server granted named tools is also granted d.SignInTool, unless d.DisallowedTools names it: the sign-in tool is the server's route to connect, not one of its tools. An MCP name in d.Tools is any name with the mcp__ prefix; one that names no tool, such as mcp__github__, grants nothing. Built-in tool names in d.Tools grant nothing here. A name that could belong to two of d.Servers, such as mcp__git___x for git and git_, applies to both.
type DelegationRecord ¶ added in v0.0.53
type DelegationRecord struct {
RecordHeader
Workload Workload
SessionID string
// ScheduleMark is the session's, when the broker knows the session.
ScheduleMark
DelegationID string
// DelegatingRun and DelegatingAgent delegate; DelegatingAgentID,
// DelegatingInstance, and DelegatingRecord are the agent's ag_
// identifier, incarnation, and latest accepted registration, when it is
// registered to the session.
DelegatingRun string
DelegatingAgent AgentRef
DelegatingAgentID string
DelegatingInstance string
DelegatingRecord string
// DelegatingRunRecorded reports that, when the report was checked, the
// broker had not seen the delegating run, so the report records it as a
// root run of DelegatingAgent. A call of that run racing the report may
// record the same run first; the run is the same either way.
DelegatingRunRecorded bool
// StandInDelegatingRun reports that DelegatingRun stands in for the API
// request that started the work, as for the run of the root's main agent
// mecak8s starts for each RunTeam call: the main agent did not delegate.
StandInDelegatingRun bool
// ParentDelegationRecord is the AuditID of the delegation the delegating
// run itself acts under; empty for a root run.
ParentDelegationRecord string
// PreviousRecord is the AuditID of the latest accepted report of the
// same delegation in an earlier broker session of the root host
// session, as when mecak8s reports it again after a reopen; empty for a
// first report.
PreviousRecord string
// ReceivingRun, its RunOwner, and ReceivingAgent receive the work;
// ReceivingAgentID and ReceivingRecord as for the delegating agent.
ReceivingRun string
ReceivingAgent AgentRef
ReceivingAgentID string
ReceivingRecord string
RunOwner Owner
// UserRecord is the AuditID of the open that verified the session's
// user, and User that user; empty when none did.
UserRecord string
User User
// Owner is the broker session's owner, as mecak8s reported it, as in
// the other records.
Owner Owner
// LineageProvenance marks the delegation's facts, its runs, agents, run
// owner, and stand-in mark, which only mecak8s observes. It is always reported by
// mecak8s (audit.md, "Lineage").
LineageProvenance SubjectProvenance
}
DelegationRecord records a ReportDelegation call as a delegation lineage event, or a refused report with its reason (audit.md, "Lineage"; credentials-and-lifecycle.md, "Delegation report"). Every fact in it is reported by mecak8s; an accepted report was checked for consistency. An identical repeat of an accepted report makes no second record.
func (*DelegationRecord) Header ¶ added in v0.0.53
func (r *DelegationRecord) Header() RecordHeader
Header implements Record.
func (*DelegationRecord) Subjects ¶ added in v0.0.53
func (r *DelegationRecord) Subjects() Subjects
Subjects implements Record. The acting agent is the delegating one, as mecak8s reported it.
type DeliveryFailure ¶ added in v0.0.53
DeliveryFailure is a record the sink refused or the broker dropped unsent: its AuditID and type, never its content, and the error. A record still being sent when Close gives up is reported as not confirmed, and its send then finishes on its own: the sink may still accept it, or refuse it, which reports it a second time with the sink's error.
type Digest ¶
Digest is a content digest in canonical form: a supported algorithm and the lowercase hexadecimal digest value. The canonical form makes value equality mean digest equality.
type DispatchOutcome ¶ added in v0.0.53
type DispatchOutcome string
DispatchOutcome is a reported attempt's dispatch, in audit.md's fixed set for the Dispatch event. Its values are the matching DecisionOutcome strings, which the broker's records carry.
const ( // DispatchSuccess means the tools/call was, or may have been, sent: it // may have run. DispatchSuccess DispatchOutcome = "success" // DispatchFailure means the MCP client reports the tools/call was never // sent. DispatchFailure DispatchOutcome = "failure" )
type DispatchRecord ¶ added in v0.0.53
type DispatchRecord struct {
RecordHeader
CallReport
}
DispatchRecord records a reported dispatch: Outcome is success when the tools/call was or may have been written, and failure when it never was.
func (*DispatchRecord) Header ¶ added in v0.0.53
func (r *DispatchRecord) Header() RecordHeader
Header implements Record.
func (*DispatchRecord) Subjects ¶ added in v0.0.53
func (r *DispatchRecord) Subjects() Subjects
Subjects implements Record.
type Error ¶
type Error struct {
Code Code
Reason Reason
Detail string
// ScheduleEnd is why a scheduled run's schedule no longer gives it
// authority, on a refused open naming a schedule: what ended it, where
// Reason says only what the caller does next, such as
// ReasonSetupRequired for several ends; empty otherwise.
ScheduleEnd ScheduleEndCause
}
Error is the error every Service call returns. Detail is for diagnostics; it never contains credentials.
func ReasonError ¶
ReasonError returns an *Error for reason with the code the design assigns.
type ExchangeGrant ¶ added in v0.0.52
type ExchangeGrant struct {
Type string
IssuableTokenTypes []string
// ExpiresAt is zero when the entry has no expires_at.
ExpiresAt time.Time
}
ExchangeGrant is an exchange-grant authorization_details entry.
type FindScheduleRequest ¶ added in v0.0.53
type FindScheduleRequest struct {
ScheduleID string
}
FindScheduleRequest finds what the broker holds for a schedule.
func (FindScheduleRequest) Validate ¶ added in v0.0.53
func (r FindScheduleRequest) Validate() error
Validate reports whether r is well formed. The error is an *Error with CodeInvalidArgument.
type FindSessionRequest ¶
type FindSessionRequest struct {
RootHostSessionID string
}
FindSessionRequest finds the open broker session for a root host session.
func (FindSessionRequest) Validate ¶
func (r FindSessionRequest) Validate() error
Validate reports whether r is well formed. The error is an *Error with CodeInvalidArgument.
type Gateway ¶ added in v0.0.52
type Gateway struct {
// Issuer and Resource are the AS-2 issuer and vMCP resource the gateway's
// entry names. The AS-2 bound for the gateway must name both.
Issuer, Resource string
// Servers are the backend names the gateway routes. A call naming any
// other server is denied.
Servers []string
// AS2 is the gateway's authorization server. The zero value leaves it
// unbound until BindGatewayAS2.
AS2 GatewayAS2
}
Gateway is the MCP gateway the broker authorizes calls through, built from its gateway entry.
type GatewayAS2 ¶ added in v0.0.52
type GatewayAS2 struct {
// Issuer is AS-2's issuer, an ID-JAG's audience.
Issuer string
// Resource is the vMCP resource, an ID-JAG's resource.
Resource string
// AuthServer redeems ID-JAGs at AS-2's token endpoint.
AuthServer GatewayAuthServer
}
GatewayAS2 is the gateway's authorization server, AS-2, as the broker uses it: the audience of the ID-JAGs it requests, the vMCP resource, and the port that redeems ID-JAGs there.
type GatewayAuthServer ¶ added in v0.0.52
type GatewayAuthServer interface {
Redeem(ctx context.Context, req Redemption) (GatewayTokenResult, error)
}
GatewayAuthServer is AS-2's token endpoint as a call uses it, design step (8): the RFC 7523 JWT-bearer redemption of an ID-JAG for a gateway token. The token endpoint and HTTP client live in the adapter, as the core holds no network client. Its errors follow IDJAGIssuer's.
type GatewayEntry ¶ added in v0.0.53
type GatewayEntry struct {
Kind GatewayKind
// AS2Issuer is the gateway's authorization server's issuer, an ID-JAG's
// audience.
AS2Issuer string
// TokenEndpoint is AS-2's token endpoint as AS-2 advertises it, never a
// dial address.
TokenEndpoint string
// Resource is the gateway's vMCP resource, an ID-JAG's resource.
Resource string
// Servers are the backend names the gateway routes. An entry may route
// none, which configures no gateway.
Servers []string
}
GatewayEntry is a gateway the operator declares in the broker's configuration. Its AS-2 issuer and resource are the target AS-1 issues the gateway's ID-JAGs for, and its servers are the ones check 6 lets calls reach through it.
type GatewayKind ¶ added in v0.0.53
type GatewayKind string
GatewayKind is a gateway entry's kind.
const ( // GatewayEmbedded is the gateway the process serving the broker's caller // runs: mecak8s's embedded vMCP, whose authorization server is AS-2. GatewayEmbedded GatewayKind = "embedded" // GatewayExternal is a gateway run elsewhere, with its own AS-2. GatewayExternal GatewayKind = "external" )
The gateway kinds an entry may name.
type GatewayTokenResult ¶ added in v0.0.52
type GatewayTokenResult struct {
AccessToken Token
// ExpiresIn is AS-2's expires_in, zero when it sent none.
ExpiresIn time.Duration
// AuthorizationDetails is the response's authorization_details member as
// AS-2 sent it, nil when absent. The broker checks it against the call
// entry it sent (step (8a)).
AuthorizationDetails json.RawMessage
}
GatewayTokenResult is AS-2's answer to a redemption.
type Host ¶ added in v0.0.53
type Host struct {
// AS1 reports that the process hosts AS-1, which requires the broker
// client key and AS-1's signing key; only a hosted AS-1 takes AS-1's
// signing key.
AS1 bool
// AS1Issuer is the issuer of the AS-1 the broker uses, hosted or not;
// empty without one. No gateway entry's AS-2 issuer may name it.
AS1Issuer string
}
Host is what the process runs beside the broker, which decides the keys Keys.Validate requires and accepts.
type IDJAGIssuer ¶ added in v0.0.52
type IDJAGIssuer interface {
IssueIDJAG(ctx context.Context, req IDJAGRequest) (IDJAGResult, error)
}
IDJAGIssuer is AS-1's token endpoint as a call uses it, design step (7): the RFC 8693 exchange of the session's refresh token, with the agent's SVID as the actor token, for an ID-JAG addressed to AS-2. Its errors follow AuthServer's: a refusal is a *ServerRefusal; a request with no response wraps ErrNoResponse; a misconfigured connection wraps ErrTransportConfiguration; a success response it cannot decode, or whose issued_token_type is not an ID-JAG's, wraps both ErrMalformedResponse and ErrTransportConfiguration. The core separately checks the token's header typ. Errors never carry a token.
type IDJAGRecord ¶ added in v0.0.52
type IDJAGRecord struct {
RecordHeader
SessionID string
ScheduleMark
Workload Workload
Agent AgentRef
AgentID string
RunID string
// DelegationID is the delegation the run acts under; empty for a root
// run.
DelegationID string
// RunOwner is the owner the run acts for, as reported.
RunOwner Owner
// Owner is the company identity of the grant the ID-JAG was exchanged
// from, User its verified user (AS-1's subject and client), and
// UserRecord the AuditID of the record that verified the user: the open
// that stored the grant, or, in a session opened from a schedule, the
// schedule's setup or renewal record, as in the other records.
Owner Owner
UserRecord string
User User
// AgentInstance is the acting agent's incarnation, as mecak8s reported
// it at registration.
AgentInstance string
// RegistrationRecord is the AuditID of the acting agent's latest
// accepted registration; DelegationRecord that of the delegation the run
// acts under, empty for a root run.
RegistrationRecord string
DelegationRecord string
OperationID string
AttemptID string
IDJAG CredentialRef
ExpiresAt time.Time
}
IDJAGRecord records an ID-JAG the broker obtained for a call, before it is redeemed.
func (*IDJAGRecord) Header ¶ added in v0.0.53
func (r *IDJAGRecord) Header() RecordHeader
Header implements Record.
func (*IDJAGRecord) Subjects ¶ added in v0.0.53
func (r *IDJAGRecord) Subjects() Subjects
Subjects implements Record. The user is the grant's, from the open that stored it.
type IDJAGRequest ¶ added in v0.0.52
type IDJAGRequest struct {
// SubjectToken is the session's refresh token.
SubjectToken Token
// ActorToken is the acting agent's SVID.
ActorToken Token
// Audience is AS-2's issuer.
Audience string
// Resource is the vMCP resource the gateway token is for.
Resource string
// AuthorizationDetails is the call entry AS-1 signs into the ID-JAG, a
// JSON array of one entry of CallEntryType. The adapter omits the
// parameter when it is empty.
AuthorizationDetails json.RawMessage
}
IDJAGRequest is a per-call ID-JAG exchange request.
type IDJAGResult ¶ added in v0.0.52
type IDJAGResult struct {
IDJAG Token
}
IDJAGResult is AS-1's answer to an ID-JAG exchange.
type JWK ¶ added in v0.0.52
type JWK struct {
KeyType string `json:"kty"`
Curve string `json:"crv"`
X string `json:"x"`
Y string `json:"y"`
KeyID string `json:"kid"`
Use string `json:"use"`
Algorithm string `json:"alg"`
}
JWK is a public EC signing key as an RFC 7517 JSON Web Key.
type JWKSet ¶ added in v0.0.52
type JWKSet struct {
Keys []JWK `json:"keys"`
}
JWKSet is an RFC 7517 JWK Set.
type Keys ¶ added in v0.0.53
type Keys struct {
// AgentIssuer signs agent credentials. It is always required.
AgentIssuer crypto.Signer
// AgentIssuerFallbacks are earlier agent issuer public keys, each ECDSA
// P-256: credentials they signed still verify while they are configured
// (WithAgentIssuerFallbacks).
AgentIssuerFallbacks []crypto.PublicKey
// BrokerClient signs the broker's client assertions at AS-1 and AS-2
// (NewClientAssertionSigner). It is required with a hosted AS-1.
BrokerClient crypto.Signer
// BrokerClientKeySet is the broker client's public JWK Set that AS-1 and
// AS-2 register for BrokerClientID. It must hold BrokerClient's public key
// under its kid, and may hold another key during a rotation. It is
// required with BrokerClient and only with it.
BrokerClientKeySet []byte
// AS1Signing are AS-1's signing key's public key, then its fallbacks'.
// AS-1 reads the keys itself; the broker holds them only to refuse a key
// used for two roles. The signing key is required with a hosted AS-1 and
// refused without one.
AS1Signing []crypto.PublicKey
}
Keys are the identity broker's operator-supplied keys, one per role. A deployment never generates them: a restart keeps every key, so the credentials, assertions, and tokens they sign keep verifying.
func (Keys) PublicKeys ¶ added in v0.0.53
PublicKeys returns the public keys of every role in k: the agent issuer key and its fallbacks, the broker client's key set's ECDSA P-256 keys, which include the broker client key's, and AS-1's signing keys. A process holding a key for another role, such as the embedded gateway's signing key, refuses one of these.
func (Keys) Validate ¶ added in v0.0.53
Validate checks k for a broker beside host. It refuses a missing required key, an AS-1 signing key without a hosted AS-1, an agent issuer fallback that is not ECDSA P-256, one key used for two roles, including any P-256 key in the broker client's key set, and a broker client key set that holds no key or not the broker client key's public key under its kid. Errors wrap ErrInvalidConfig or ErrInvalidSigner and never contain key material.
type Limits ¶ added in v0.0.53
type Limits struct {
// IDJAGMaxLifetime is a hosted AS-1's maximum lifetime for the grants
// that issue ID-JAGs (ToolHive's id_jag_max_lifetime on the
// BrokerClientID delegate client), and so every session's hard expiry:
// whole seconds from 1s to MaxIDJAGMaxLifetime, and at least ten clock
// skews. It is required with a hosted AS-1 and refused without one.
IDJAGMaxLifetime time.Duration
// ScheduleGrantMaxLifetime is a hosted AS-1's maximum lifetime for the
// grants that issue refresh tokens (ToolHive's refresh_token_max_lifetime
// on the BrokerClientID delegate client), and so the longest horizon a
// schedule's setup can get: whole seconds from 1s to
// MaxScheduleGrantMaxLifetime, and at least ten clock skews. It is set
// apart from IDJAGMaxLifetime, never derived from it. It is optional with
// a hosted AS-1, where zero issues no schedule grants, and refused without
// one.
ScheduleGrantMaxLifetime time.Duration
// IDJAGLifetime is the lifetime of each ID-JAG a hosted AS-1 issues for a
// gateway entry, which also bounds the gateway token's, as AS-2 caps it at
// the ID-JAG's remaining validity: whole seconds from 1s to
// MaxIDJAGLifetime. It is required with a hosted AS-1 and refused without
// one.
IDJAGLifetime time.Duration
// ClientAssertionLifetime is the lifetime of each client assertion the
// broker signs (NewClientAssertionSigner): whole seconds from 1s to
// MaxClientAssertionLifetime.
ClientAssertionLifetime time.Duration
// AS1RequestTimeout bounds one request the broker makes at AS-1, from 1s
// to MaxAS1RequestTimeout. Session open holds the host session's open
// lock while it makes at most two, the exchange and one resend, so this
// bounds how long that lock is held. Once AS-1 re-checks the user at the
// upstream IdP during an exchange (#2568), it must exceed that re-check's
// lease wait plus the IdP call.
AS1RequestTimeout time.Duration
// AS2RequestTimeout bounds one request the broker makes at a gateway's
// AS-2, from 1s to MaxAS2RequestTimeout.
AS2RequestTimeout time.Duration
}
Limits are the broker's operator-set lifetimes and timeouts that its host applies around the core: AS-1's ID-JAG and schedule grant settings, the client-assertion signer's lifetime, and the request timeouts of the broker's calls to AS-1 and AS-2. The configuration loader resolves their defaults; Validate checks them. Config holds the lifetimes and skew New applies itself.
type ObservedOutcome ¶ added in v0.0.53
type ObservedOutcome string
ObservedOutcome is the outcome the MCP client observed of a dispatched attempt, in audit.md's fixed set for the Observed outcome event. Its values are the matching DecisionOutcome strings.
const ( ObservedSuccess ObservedOutcome = "success" ObservedFailure ObservedOutcome = "failure" ObservedError ObservedOutcome = "error" ObservedUnknown ObservedOutcome = "unknown" )
Observed outcomes; ObservedUnknown means the call may have run but no completion was observed.
type OpenKind ¶ added in v0.0.53
type OpenKind string
OpenKind is how a successful session open treated the request's access token or, for an open naming a schedule, the schedule's grant.
const ( // OpenConverted means AS-1 converted the access token into the session's new // refresh token. OpenConverted OpenKind = "converted" // OpenAlreadyConverted means AS-1 may already have converted the token, and // the session, holding a live refresh token, was returned as it was. OpenAlreadyConverted OpenKind = "already_converted" // OpenTokenless means the request carried no access token, or the broker // converts none, so the session was only paired with the reported owner. OpenTokenless OpenKind = "tokenless" // OpenSchedule means AS-1 exchanged the schedule's grant, its stored one // for a run or a pending one for its setup, for the session's refresh // token, a child of that grant. OpenSchedule OpenKind = "schedule" // OpenScheduleNoGrant means the schedule held no stored grant, so the // run's session opened without one, as a tokenless open does. OpenScheduleNoGrant OpenKind = "schedule_no_grant" // OpenScheduleAlreadyOpen means the host session's broker session, // opened from the same schedule, was open, and was returned as it was. OpenScheduleAlreadyOpen OpenKind = "schedule_already_open" )
type OpenSessionRequest ¶
type OpenSessionRequest struct {
HostSessionID string
// Incarnation is the host session's incarnation, which its main agent
// registers with, so it must be a Mecatl incarnation (see
// RegisterAgentRequest.Incarnation).
Incarnation string
Owner Owner
// AccessToken is the user's AS-1 access token, when the request has one.
// A broker that converts tokens checks that its sub_id is Owner and
// exchanges it at AS-1 for the session's refresh token. AS-1 converts each
// token once, so the caller passes a freshly refreshed token, and need not
// pass one while the session holds a live refresh token; a token AS-1 may
// already have converted, for any session, is not exchanged again. A
// token not converted before replaces the session's refresh token. Other
// brokers ignore it.
AccessToken Token
// ScheduleID opens the session from the schedule's grant instead of an
// access token, which the request then carries none of: for one of the
// schedule's runs or, with SetupID, for its setup's listing (design
// "Scheduled-run session open" and "Schedule setup", "Connections").
ScheduleID string
// SetupID names the schedule's pending setup whose grant the setup's own
// listing session is opened from. That session belongs to the setup, not
// to a host session or a run: the request names no host session or
// incarnation, and the broker allocates both, which Session returns for
// the root instance to register with.
SetupID string
// Digest is a run's digest of its schedule as it stands, computed under
// the version the schedule's setup recorded. When the schedule holds a
// stored grant, it must equal the digest that setup stored, or the run is
// refused with ReasonSetupRequired; a schedule holding none opens without
// one whatever the digest. It is zero for a setup's session, whose setup
// carries its own.
Digest ScheduleDigest
// Trigger is what started a scheduled run: its schedule's timer, or a
// manual fire such as a retry. Both open through the same checks; the
// open records which (ScheduleConsent.Trigger). Only a run's open
// carries one, and it may leave it unset.
Trigger ScheduleTrigger
}
OpenSessionRequest opens the broker session for a root host session.
func (OpenSessionRequest) Validate ¶
func (r OpenSessionRequest) Validate() error
Validate reports whether r is well formed. The error is an *Error with CodeInvalidArgument.
type Option ¶ added in v0.0.52
type Option func(*Broker)
Option configures a Broker in New.
func WithAgentIssuerFallbacks ¶ added in v0.0.53
WithAgentIssuerFallbacks has the broker also verify agent credentials signed by keys, earlier agent issuer keys, so credentials issued before a rotation keep verifying. Each must be an ECDSA P-256 public key; New copies them and refuses any other with ErrInvalidSigner.
func WithAuthServer ¶ added in v0.0.52
func WithAuthServer(as1 AuthServer) Option
WithAuthServer has OpenSession convert the access token of a request that carries one at as1 (design step (3)). Without it, or with nil, the broker ignores access tokens and every open only pairs its session.
func WithClock ¶ added in v0.0.52
WithClock replaces the broker's clock, which times session hard expiry, converted-token memory, and agent credentials, so a test can move past a session's hard expiry. Without it the broker uses time.Now.
func WithDeliveryFailures ¶ added in v0.0.53
func WithDeliveryFailures(report func(DeliveryFailure)) Option
WithDeliveryFailures has the broker report each record its sink refuses to report, apart from the records, so a failing sink does not hide its own failure (audit.md, "Write order and failure"), and each record it drops unsent: past the queue's bound, or at Close. Without it, or with nil, refused records are reported nowhere but in the failing operation's error, and a refusal or close whose record is refused in none. report may be called with the broker's locks held, so it must return promptly and must not call the broker.
Shortcut: delivery failures are reported to a callback, which mecak8s logs, not on a separate delivery-failure channel; removed by #2848.
func WithGateway ¶ added in v0.0.52
WithGateway has AuthorizeCall authorize calls through g. Without it every call that reaches the server check is denied. New refuses a second WithGateway, a gateway without an issuer or resource, with no servers, with a server name that is not letters, digits, and single underscores or that appears twice, or with a partly set AS2 or one naming another issuer or resource, and a gateway without WithRecorder and WithIDJAGIssuer. New binds a non-zero AS2.
Shortcut: one gateway; removed by #2812 (several gateways, each with its own AS-2).
func WithIDJAGIssuer ¶ added in v0.0.52
func WithIDJAGIssuer(as1 IDJAGIssuer) Option
WithIDJAGIssuer has AuthorizeCall obtain each call's ID-JAG at as1 (design step (7)). A gateway requires it.
func WithRecorder ¶ added in v0.0.52
WithRecorder has the broker send every record to r. Without it, or with nil, nothing is recorded; a gateway requires one.
func WithoutScheduleGrants ¶ added in v0.0.53
func WithoutScheduleGrants() Option
WithoutScheduleGrants has BeginScheduleSetup refuse every setup with CodeFailedPrecondition, without calling AS-1, for an AS-1 that issues no schedule grants, such as a hosted one with no Limits.ScheduleGrantMaxLifetime.
type OutcomeRecord ¶ added in v0.0.53
type OutcomeRecord struct {
RecordHeader
CallReport
// LateResult marks a result observed after the attempt's outcome was
// reported unknown; Follows is the AuditID of that unknown outcome's
// record (audit.md, "Correlation").
LateResult bool
Follows string
}
OutcomeRecord records a reported observed outcome of a dispatched attempt: success, failure, error, or unknown when it may have run but no completion was observed.
func (*OutcomeRecord) Header ¶ added in v0.0.53
func (r *OutcomeRecord) Header() RecordHeader
Header implements Record.
func (*OutcomeRecord) Subjects ¶ added in v0.0.53
func (r *OutcomeRecord) Subjects() Subjects
Subjects implements Record.
type Owner ¶
Owner is a session owner: the user's company identity, such as issuer "https://login.example.com" and subject "alice-204".
func OwnerFromSubjectIdentifier ¶ added in v0.0.53
OwnerFromSubjectIdentifier parses raw, an RFC 9493 subject identifier as JSON, such as an access token's or a grant's sub_id, into the owner it names. Only format iss_sub with a valid issuer and subject is accepted, the rule session open applies. Members are read by exact name, as other readers of sub_id do, not case-insensitively as decoding into a struct would. A failure is a CodeInvalidArgument *Error whose text never contains the identifier's values.
type Provenance ¶
type Provenance struct {
// Profile identifies the provenance profile, such as "git/v1".
Profile string
// Metadata holds profile-specific facts, such as a repository and path.
// Keys must be non-empty printable text without spaces; values must be
// valid UTF-8. A nil and an empty map are equivalent.
Metadata map[string]string
// SourceDigest is the digest of the bytes read from the source.
SourceDigest Digest
// DefinitionDigest is the digest of the normalized definition the loader
// accepted. It differs from SourceDigest whenever parsing normalizes input.
DefinitionDigest Digest
}
Provenance records where a loaded definition came from and what was accepted. The profile names the source kind and versions the meaning of Metadata; this package requires a profile but does not interpret it.
type Reason ¶
type Reason string
Reason is a design-defined reason code that tells the caller what to do, such as opening a new broker session. Reasons are lowercase letters and underscores.
const ( // ReasonSessionClosed: the broker session is closed; open a new one on the // user's next request. ReasonSessionClosed Reason = "session_closed" // ReasonSessionOwned: the host session's broker session belongs to another // owner. ReasonSessionOwned Reason = "session_owned" // ReasonDenied: the call is not allowed. ReasonDenied Reason = "denied" // ReasonSVIDExpired: the agent credential has expired; get a new one and // retry. ReasonSVIDExpired Reason = "svid_expired" // ReasonOwnerMismatch: at session open, the access token's company // identity is not the owner the caller reported; a pairing bug. ReasonOwnerMismatch Reason = "owner_mismatch" // ReasonSubjectInvalid: at session open, the access token is not // acceptable; refresh it and open once more. ReasonSubjectInvalid Reason = "subject_invalid" // ReasonTokenUsed: at session open, the access token was already // converted; refresh it and open once more. ReasonTokenUsed Reason = "token_used" // ReasonSignedOut: the user signed out everywhere; stop the run. At // session open mecak8s answers it with a 401, so the client signs in // again. ReasonSignedOut Reason = "signed_out" // ReasonUpstreamRevoked: the company IdP revoked the user's sign-in; stop // the run. At session open mecak8s answers it with a 401, so the client // signs in again. ReasonUpstreamRevoked Reason = "upstream_revoked" // ReasonOwnerActionRequired: the user must sign in again. ReasonOwnerActionRequired Reason = "owner_action_required" // ReasonScheduleEnded: the schedule was deleted, so it is never set up // again and its runs do not start. ReasonScheduleEnded Reason = "schedule_ended" // ReasonSetupRequired: a scheduled run's schedule needs setup again, as // it changed since setup or its grant's horizon passed; the run does not // start. Signing in again would not help, so it is not // ReasonOwnerActionRequired. ReasonSetupRequired Reason = "setup_required" // ReasonNoGrant: the broker session holds no refresh token, so no call // can be authorized in it; open the session with an access token. ReasonNoGrant Reason = "no_grant" // ReasonConsentRequired: the gateway's authorization server needs the // user's consent before it issues a token for the call. ReasonConsentRequired Reason = "consent_required" // ReasonSubjectUnknown: the gateway's authorization server does not know // the user, who has never signed in at the gateway; they sign in there, // connecting their accounts, and the call is made again with a new // authorization. It is not retried with a new ID-JAG. ReasonSubjectUnknown Reason = "subject_unknown" // ReasonCallEntryMissing: AS-2's token response carries no call entry // (step (8a), check 1). The gateway token is discarded; the call fails // with CodeInternal and is not retried. ReasonCallEntryMissing Reason = "call_entry_missing" // ReasonCallEntryMismatch: AS-2's token response carries a call entry // other than the one the broker sent (step (8a), check 2). As for // ReasonCallEntryMissing. ReasonCallEntryMismatch Reason = "call_entry_mismatch" // ReasonRecordNotAccepted: the broker's audit sink did not accept, within // its deadline, a record the operation waits for, so the operation changed // nothing (credentials-and-lifecycle.md, "Error reasons"). What follows // depends on the operation: // - an open that converted the request's token fails with // CodeUnauthenticated, as token_used: the token is spent, so the // client refreshes it and opens again (mecak8s answers a repeat of // the same caller's failure within a minute as unavailable instead); // - any other open, an ID-JAG, or a call fails with CodeUnavailable and // is retried as an infrastructure error; // - a new helper's or team member's first registration or delegation // report is not retried: it does not run; // - the root's registration is retried when its run starts, and a // re-registration or a delegation reported again after a reopen on // the agent's next call. // Because of the first variant its code is not always Code(), so // errors.Is with ReasonError(ReasonRecordNotAccepted, "") misses a // converted open: match on the reason, as mecak8s does. ReasonRecordNotAccepted Reason = "record_not_accepted" )
Reasons a Service error can carry. Later work adds the design's other reasons as it returns them.
func (Reason) RequiresConnection ¶ added in v0.0.54
RequiresConnection reports whether r is a refusal the user fixes by connecting their account at the gateway or approving Mecatl there: AS-2 does not know them (subject_unknown) or wants their approval (consent_required). Nobody is present in a scheduled run to do either, so schedule setup leaves out a server that refuses this way, and a scheduled run's listing or gateway call that meets one ends the run as needing its schedule's owner to act.
func (Reason) RequiresSignIn ¶ added in v0.0.52
RequiresSignIn reports whether r is a user-wide revocation of the user's authority (signed_out, upstream_revoked, owner_action_required): a refreshed access token is refused too, so the user signs in again.
type Record ¶ added in v0.0.53
type Record interface {
// Header returns what every record carries.
Header() RecordHeader
// Subjects returns the record's subjects by audit.md's Subjects keys,
// each with its provenance. Every key the record's event names is
// present; a subject the broker does not have is marked unavailable.
Subjects() Subjects
// contains filtered or unexported methods
}
Record is one of the broker's records: *SessionOpenRecord, *SessionCloseRecord, *RegistrationRecord, *DelegationRecord, *IDJAGRecord, *DecisionRecord, *DispatchRecord, *OutcomeRecord, *ReportRejectedRecord, *ScheduleSetupRecord, *ScheduleRevokedRecord, or *ScheduleExpiredRecord.
type RecordHeader ¶ added in v0.0.53
type RecordHeader struct {
// AuditID identifies the record: minted once, when the broker makes the
// record, and never shared with another record.
AuditID string
// Type is the record's AuditEvent type, one of the Type constants. The
// broker sets it; Header returns the record's own type whatever it holds.
Type string
// At is when the event happened, on the broker's clock; for a call
// report's records, when the broker received the report.
At time.Time
Outcome DecisionOutcome
// Code and Reason are a refusal's; empty on success.
Code Code
Reason Reason
// Supersedes is the AuditID of this event's success record, for a
// refusal recorded after it because the event could not take effect:
// the sink did not confirm the success, which it may still have kept, or
// the session closed while the success was recorded. Records are never
// edited; this one follows the earlier one.
Supersedes string
}
RecordHeader is what every record carries.
type Recorder ¶ added in v0.0.52
Recorder is the sink the broker's records go through: every open, close, registration, delegation report, ID-JAG, call decision, and reported dispatch and outcome. Record returns nil once it accepts rec, and an error when it refuses it. A refusal is handled per event: a successful open, registration, or delegation report fails with ReasonRecordNotAccepted and changes nothing; an ID-JAG is not redeemed and a success decision returns no gateway token, both failing with ReasonRecordNotAccepted; refusals, closes, and call reports take effect anyway. An event undone after its record was sent is recorded again as refused, superseding that record, since the sink may have kept it without confirming it. Every refused record is reported through WithDeliveryFailures. Records are *SessionOpenRecord, *SessionCloseRecord, *RegistrationRecord, *DelegationRecord, *IDJAGRecord, *DecisionRecord, *DispatchRecord, *OutcomeRecord, or *ReportRejectedRecord. The broker owns rec and may reuse it after the call, so the sink copies what it keeps, including the maps a record holds, such as CallReport.DecisionSubjects. An implementation is safe for concurrent use.
type Redemption ¶ added in v0.0.52
type Redemption struct {
// Assertion is the ID-JAG.
Assertion Token
// Resource is the vMCP resource.
Resource string
}
Redemption is an ID-JAG redemption request. It carries no authorization_details: AS-2 takes the call entry only from the claim AS-1 signed into the ID-JAG, and refuses the parameter.
type RegisterAgentRequest ¶
type RegisterAgentRequest struct {
SessionID string
// HostSessionID is the agent's own host session. With no Parent it must
// equal the broker session's root host session. A child agent's is its own
// child session; ParentHostSessionID ties it to its parent.
HostSessionID string
// Owner must equal the broker session's owner.
Owner Owner
// Incarnation is the agent instance's incarnation, which the harness
// allocates and persists: its host session's incarnation. With no Parent
// it must equal the broker session's incarnation. The broker keys agents
// by it. It must be a Mecatl incarnation: inc_ and 26 lowercase base32
// characters, or legacy_ and 64 hex characters.
Incarnation string
// Definition is the definition the instance runs. Name is required, and a
// new instance's reference must be exactly one the broker loaded, so it
// registers only with Source and Revision set. Source and Revision may
// still be empty in a request, which the broker then refuses as not
// loaded, until sessions record their exact reference (#2548).
Definition DefinitionRef
// Parent is the registered instance that created this one; zero for a
// session's main agent.
Parent AgentRef
// ParentHostSessionID is the host session the child's session was created
// under, as the harness records it, or the root host session for a member
// of a team created over the API, whose session records none and whose
// parent is the root's main agent. It is required with Parent and must be
// empty without one. The broker refuses a child whose ParentHostSessionID
// is not its parent's recorded host session, so each child is tied to its
// parent and, through it, to the session's tree.
ParentHostSessionID string
// StandInParent marks Parent as standing in for the API request that
// created the instance, as for a member of a team created over the API:
// the root's main agent is its parent in the tree, but did not create
// it. It requires Parent, which must be the session's root instance. An
// instance registered again must report the same mark (check 7).
StandInParent bool
}
RegisterAgentRequest registers an agent instance in a broker session.
func (RegisterAgentRequest) Validate ¶
func (r RegisterAgentRequest) Validate() error
Validate reports whether r is well formed. The error is an *Error with CodeInvalidArgument.
type Registration ¶
type Registration struct {
Agent AgentRef
Credential Token
// ExpiresAt is when the credential expires. Register again before then
// for a fresh one.
ExpiresAt time.Time
}
Registration is a registered agent instance and its credential. Mecatl's trusted harness code holds the credential and presents it on each call; it never reaches the engine or the model.
type RegistrationRecord ¶ added in v0.0.53
type RegistrationRecord struct {
RecordHeader
Workload Workload
SessionID string
// ScheduleMark is the session's, when the broker knows the session.
ScheduleMark
// SessionRecord is the AuditID of the open that created the session.
SessionRecord string
HostSessionID string
Owner Owner
Incarnation string
Definition DefinitionRef
// Agent and AgentID are the instance's SPIFFE ID and ag_ identifier;
// zero for a refusal before the broker knew the instance.
Agent AgentRef
AgentID string
// New reports that the instance registered for the first time; Moved
// that it moved from another broker session.
New, Moved bool
// PreviousRecord is the AuditID of the instance's previous accepted
// registration; empty for a new instance.
PreviousRecord string
// Parent is the instance's creation parent; zero for a main agent.
Parent AgentRef
ParentHostSessionID string
// ParentRecord is the AuditID of the parent's latest accepted
// registration.
ParentRecord string
// StandInParent reports that Parent stands in for the API request that
// created the instance, as for a member of a team created over the API:
// Parent is the root's main agent, which did not create the instance.
StandInParent bool
// CredentialExpiresAt is when the issued credential expires.
CredentialExpiresAt time.Time
// UserRecord is the AuditID of the open that verified the session's
// user, and User that user; empty when none did.
UserRecord string
User User
// LineageProvenance marks the instance's place in the tree, which only
// mecak8s observes: HostSessionID, Incarnation, Definition, Parent,
// ParentHostSessionID, StandInParent, and the records they lead to. It
// is always reported by mecak8s (audit.md, "Lineage").
LineageProvenance SubjectProvenance
}
RegistrationRecord records a RegisterAgent call as a registration lineage event, or a refused registration with its reason (audit.md, "Lineage"; credentials-and-lifecycle.md step (4), "Evidence"). Everything about the instance's place in the tree is reported by mecak8s; the agent's identity is the broker's own.
func (*RegistrationRecord) Header ¶ added in v0.0.53
func (r *RegistrationRecord) Header() RecordHeader
Header implements Record.
func (*RegistrationRecord) Subjects ¶ added in v0.0.53
func (r *RegistrationRecord) Subjects() Subjects
Subjects implements Record.
type ReplacedGrant ¶ added in v0.0.53
ReplacedGrant refers to a refresh token an open replaced, never by value: by the open record that stored it and that open's source token jti.
type ReportCallRequest ¶ added in v0.0.53
type ReportCallRequest struct {
// SessionID is the broker session the attempt was authorized in.
SessionID string
// OperationID and AttemptID name the call and the attempt, as
// AuthorizeCallRequest.OperationID and Authorization.AttemptID did.
OperationID string
AttemptID string
// Dispatch is DispatchSuccess when the tools/call was, or may have been,
// sent, and DispatchFailure when it never was (audit.md, "AuditEvent
// profile").
Dispatch DispatchOutcome
// Outcome is the outcome observed of a dispatched call. Empty when
// Dispatch is DispatchFailure.
Outcome ObservedOutcome
// LateResult reports a result observed after the attempt's outcome was
// reported unknown: a new observed outcome of the same attempt, never
// unknown.
LateResult bool
// Cause is the client's fixed code for why the attempt was not sent or
// was refused, such as invalid_token; empty when it has none. It is
// lowercase letters, digits, and underscores, at most maxCauseBytes.
Cause string
}
ReportCallRequest reports one attempt of a tools/call the broker authorized, as the MCP client that sent it observed it. It carries no credential, arguments, or result content: only references and fixed values.
func (ReportCallRequest) Validate ¶ added in v0.0.53
func (r ReportCallRequest) Validate() error
Validate reports whether r is well formed. The error is an *Error with CodeInvalidArgument.
type ReportDelegationRequest ¶ added in v0.0.53
type ReportDelegationRequest struct {
SessionID string
// DelegationID identifies the delegation within the session. Calls of the
// receiving run name it in AuthorizeCallRequest.DelegationID.
DelegationID string
// DelegatingRun is the run that delegates, and DelegatingAgent the agent
// it is bound to.
DelegatingRun string
DelegatingAgent AgentRef
// ReceivingRun is the new run that receives the work, and ReceivingAgent
// the agent it is bound to.
ReceivingRun string
ReceivingAgent AgentRef
// Owner is the receiving run's owner. It must equal the delegating run's.
Owner Owner
// StandInDelegatingRun marks DelegatingRun as standing in for the API
// request that started the work, as for the run of the root's main agent
// mecak8s starts for each RunTeam call: the main agent did not delegate.
// DelegatingAgent must then be the session's root instance and
// DelegatingRun one of its root runs. The mark is part of the
// delegation's content, so a repeat must report the same mark.
StandInDelegatingRun bool
}
ReportDelegationRequest reports a delegation from a run of one agent to a new run of another, both in one broker session.
func (ReportDelegationRequest) Validate ¶ added in v0.0.53
func (r ReportDelegationRequest) Validate() error
Validate reports whether r is well formed. The error is an *Error with CodeInvalidArgument.
type ReportMismatch ¶ added in v0.0.53
type ReportMismatch string
ReportMismatch names why a call report could not be joined to the decision that issued its attempt, or was refused.
const ( // MismatchAttemptUnknown means the broker did not issue the attempt in the // reported session, or the session is unknown to the caller, or the // broker has forgotten the attempt. MismatchAttemptUnknown ReportMismatch = "attempt_unknown" // MismatchOperation means the attempt was issued for another operation. MismatchOperation ReportMismatch = "operation_mismatch" // MismatchConflictingReport means the attempt was already reported with // a different dispatch, outcome, or cause. MismatchConflictingReport ReportMismatch = "conflicting_report" // MismatchUnexpectedLateResult means a late result for an attempt whose // outcome was not reported unknown, or a second, different late result. MismatchUnexpectedLateResult ReportMismatch = "unexpected_late_result" // MismatchOutcomeNotInSet means the report's dispatch or outcome is // outside its fixed set; the report was refused. MismatchOutcomeNotInSet ReportMismatch = "outcome_not_in_set" // MismatchInvalidReport means the report was refused as invalid for // another reason. MismatchInvalidReport ReportMismatch = "invalid_report" )
type ReportRejectedRecord ¶ added in v0.0.53
type ReportRejectedRecord struct {
RecordHeader
CallReport
}
ReportRejectedRecord records a call report refused as invalid, with Outcome denied and the refusal's code. It names the calling workload, the mismatch, and the request's session, operation, and attempt only when they are well formed; never the refused values themselves.
func (*ReportRejectedRecord) Header ¶ added in v0.0.53
func (r *ReportRejectedRecord) Header() RecordHeader
Header implements Record.
func (*ReportRejectedRecord) Subjects ¶ added in v0.0.53
func (r *ReportRejectedRecord) Subjects() Subjects
Subjects implements Record.
type RevokeScheduleRequest ¶ added in v0.0.53
type RevokeScheduleRequest struct {
ScheduleID string
// Deleted reports that the schedule was deleted. The broker then marks
// it ended, so a setup or run open already under way fails with
// ReasonScheduleEnded. Otherwise, as when the workload revokes it for
// its owner, the schedule holds no grant, and its runs fail with
// ReasonSetupRequired, until it is set up again. The
// broker checks no owner (Service.RevokeSchedule). A schedule that
// changes need not be revoked: its digest changes, so its runs are
// refused until it is set up again.
Deleted bool
}
RevokeScheduleRequest ends a schedule's grants at the broker.
func (RevokeScheduleRequest) Validate ¶ added in v0.0.53
func (r RevokeScheduleRequest) Validate() error
Validate reports whether r is well formed. The error is an *Error with CodeInvalidArgument.
type ScheduleConsent ¶ added in v0.0.53
type ScheduleConsent struct {
ScheduleID string
// SetupID marks the session as the setup's own listing session, not a
// run's; empty for a run.
SetupID string
// Owner is the schedule's recorded owner; zero when the broker holds
// nothing for the schedule.
Owner Owner
// Definition is the definition the schedule runs, as setup named it.
Definition DefinitionRef
// Ceiling is the schedule's ceiling in Ceiling.String's form, and Tools
// its tool list in ToolList.String's; both empty for a setup's session,
// whose schedule has neither yet.
Ceiling string
Tools string
// Horizon is when the schedule's grant ends.
Horizon time.Time
// GrantRecord is the AuditID of the schedule's current setup or renewal
// record, which verified Owner; empty for a setup's session, or while
// the schedule has none.
GrantRecord string
// SourceJTI is the jti of the access token the schedule's grant was
// converted from, which joins the session to AS-1's conversion record;
// empty when the session was opened from no grant.
SourceJTI string
// EndCause is, on a refused open, the end of the schedule's authority
// that refused it; empty otherwise, as for a refusal of anything else.
// With GrantRecord, it records which grant ended and why. An open that
// finds the schedule already revoked or deleted names no grant, as the
// schedule holds none, and the ScheduleRevokedRecord names it instead; a
// revocation or deletion while AS-1 exchanged the grant leaves
// GrantRecord naming it.
EndCause ScheduleEndCause
// Trigger is what started a run, as mecak8s reported it; empty for a
// setup's session, or when mecak8s reported none.
Trigger ScheduleTrigger
}
ScheduleConsent is what a session opened from a schedule records of the schedule (credentials-and-lifecycle.md, "Scheduled-run session open", "Evidence"): the consent facts its run relies on, so an investigator reads who authorized the run, and until when, from its open record alone.
type ScheduleDigest ¶ added in v0.0.53
ScheduleDigest is mecak8s's digest of the schedule fields that decide what a run does (credentials-and-lifecycle.md, "Schedule setup"). The broker treats it as opaque and only compares it: mecak8s owns its fields and encoding, and Version names them, so a schedule is compared under the version it was set up with.
type ScheduleEndCause ¶ added in v0.0.54
type ScheduleEndCause string
ScheduleEndCause is what ended a schedule's authority (audit.md, "Delivery, protection, and reconciliation": the broker records each scheduled-run end with its reason). The broker's reason tells the caller what to do next and is the same for several ends, ReasonSetupRequired among them; the cause tells an investigator which end it was.
const ( // ScheduleEndHorizonReached means the schedule's grant reached its // horizon; its owner renews it. ScheduleEndHorizonReached ScheduleEndCause = "horizon_reached" // ScheduleEndChanged means the schedule changed since setup, in a field // its digest covers; its owner sets it up again. ScheduleEndChanged ScheduleEndCause = "schedule_changed" // ScheduleEndAS1Revoked means AS-1 reported the schedule's grant revoked // and the broker recorded no reason of its own for it. ScheduleEndAS1Revoked ScheduleEndCause = "as1_revoked" // ScheduleEndOwnerRevoked means the schedule's grants were revoked at the // broker without a deletion (RevokeSchedule), and it was not set up // again since. ScheduleEndOwnerRevoked ScheduleEndCause = "owner_revoked" // ScheduleEndDeleted means the schedule was deleted. ScheduleEndDeleted ScheduleEndCause = "deleted" )
type ScheduleExpiredRecord ¶ added in v0.0.54
type ScheduleExpiredRecord struct {
RecordHeader
Workload Workload
ScheduleID string
// Owner is the schedule's recorded owner.
Owner Owner
// GrantRecord is the setup or renewal record of the grant that reached
// its horizon, User that grant's user, and SourceJTI the jti of the
// access token it was converted from.
GrantRecord string
User User
SourceJTI string
// Horizon is the grant's horizon, as AS-1 granted it.
Horizon time.Time
}
ScheduleExpiredRecord records a schedule's stored grant reaching its horizon, counted one clock skew early as a run's open counts it, so the end of the schedule's authority is recorded whether or not a run comes to find it (audit.md, "Delivery, protection, and reconciliation"). The broker runs no timer: it records the end at the first of its calls after the horizon that sweeps for it (an open of any session, or a call on any schedule), once per grant, and not for a grant a renewal replaced, a revocation dropped, or a deletion ended first. Its At can precede Horizon by up to the clock skew. It is not waited for, as a close is not, and is queued again at the next sweep if the queue drops it. It is sent in order with the other queued records, so before the refusal, revocation, or close the end causes; a record the broker sends itself, not through the queue, such as a renewal's setup record or a session's open, may reach the sink first.
func (*ScheduleExpiredRecord) Header ¶ added in v0.0.54
func (r *ScheduleExpiredRecord) Header() RecordHeader
Header implements Record.
func (*ScheduleExpiredRecord) Subjects ¶ added in v0.0.54
func (r *ScheduleExpiredRecord) Subjects() Subjects
Subjects implements Record. The owner and user are the grant's, taken from its record.
type ScheduleGrantView ¶ added in v0.0.53
type ScheduleGrantView struct {
Definition DefinitionRef
// Ceiling is the schedule's ceiling: the definition's ceiling narrowed to
// the servers that listed real tools at setup.
Ceiling Ceiling
// Tools is the schedule's tool list: the tools those servers listed that
// the ceiling allows, the only tools its runs may call.
Tools ToolList
Horizon time.Time
// Record is the AuditID of the setup or renewal record that stored the
// grant.
Record string
}
ScheduleGrantView is a schedule's stored grant, without the grant itself, which never leaves the broker.
type ScheduleMark ¶ added in v0.0.54
type ScheduleMark struct {
ScheduleID string
// SetupID marks the session as the setup's own listing session, not a
// run's, so a setup's records do not read as a run's; empty for a run.
SetupID string
// GrantRecord is the AuditID of the schedule's setup or renewal record
// the session was opened from, its current grant record then; empty for
// a setup's session, or a run opened while the schedule held no grant.
GrantRecord string
}
ScheduleMark names the schedule a broker session was opened from, on every record of the session after its open (audit.md, "AuditEvent profile"), so a scheduled run's records never read as a fresh request of its owner; zero for a session opened for a user, or a record that names no session.
type ScheduleRevokeCause ¶ added in v0.0.54
type ScheduleRevokeCause string
ScheduleRevokeCause is why a ScheduleRevokedRecord dropped a schedule's grants: one of the two ends of its authority at the broker, or the drop of a pending setup, which ends nothing.
type ScheduleRevokedRecord ¶ added in v0.0.53
type ScheduleRevokedRecord struct {
RecordHeader
Workload Workload
ScheduleID string
// Cause is why the grants were dropped; Deleted derives from it.
Cause ScheduleRevokeCause
// Owner is the schedule's recorded owner; zero when the broker held
// nothing for it.
Owner Owner
// GrantRecord is the setup or renewal record of the stored grant
// dropped, User that grant's user, and SourceJTI the jti of the access
// token it was converted from, which joins the revocation to AS-1's
// conversion record; empty when none was dropped. A grant past its
// horizon is still stored, so it is named here even when a
// ScheduleExpiredRecord already recorded its end. A deletion of a
// schedule that a revocation left revoked names the grant that
// revocation dropped, since the deletion ends its authority, and
// RevokeRecord names that revocation's record.
GrantRecord string
User User
SourceJTI string
RevokeRecord string
// PendingSetup is the setup ID of a pending setup dropped, and
// PendingSourceJTI the jti of the access token its begin converted,
// which joins the drop to AS-1's conversion record; empty when none was
// pending.
PendingSetup string
PendingSourceJTI string
}
ScheduleRevokedRecord records the broker dropping a schedule's grants, as when the schedule is deleted or revoked, or only its pending setup's, when that setup is cancelled or replaced by a new one. It is recorded once the grants are dropped and is not waited for, as a close is not. A pending setup that lapses is not recorded.
func (*ScheduleRevokedRecord) Deleted ¶ added in v0.0.53
func (r *ScheduleRevokedRecord) Deleted() bool
Deleted reports that the schedule is deleted, so marked ended. It is derived from Cause, the record's one statement of it, and kept for the deleted field consumers of the record's first profile read.
func (*ScheduleRevokedRecord) Header ¶ added in v0.0.53
func (r *ScheduleRevokedRecord) Header() RecordHeader
Header implements Record.
func (*ScheduleRevokedRecord) Subjects ¶ added in v0.0.53
func (r *ScheduleRevokedRecord) Subjects() Subjects
Subjects implements Record. The owner is the one the broker recorded with the schedule's grants: taken from the grant record when a grant was stored, and otherwise, with no record to cite, as mecak8s reported it when the setup began, or unavailable when the broker held none.
type ScheduleSetup ¶ added in v0.0.53
type ScheduleSetup struct {
ScheduleID string
// SetupID names this setup to complete or cancel it. It is unguessable,
// and a later setup of the schedule gets a new one.
SetupID string
Definition DefinitionRef
// Horizon is the horizon AS-1 granted: no later than the one requested,
// and earlier when AS-1 capped it at its maximum.
Horizon time.Time
// ExpiresAt is when the broker drops the setup unless it completes.
ExpiresAt time.Time
// Renewal reports that the schedule held a grant when the setup began:
// runs keep using that grant until the renewal completes.
Renewal bool
}
ScheduleSetup is a setup or renewal begun and not yet completed. Its grant is never used for runs; it lapses at ExpiresAt unless completed first.
type ScheduleSetupRecord ¶ added in v0.0.53
type ScheduleSetupRecord struct {
RecordHeader
Workload Workload
ScheduleID string
// SetupID is the setup the record completes or refuses; empty for a
// refused begin, which made none.
SetupID string
// ReportedOwner is the owner the caller reported.
ReportedOwner Owner
// User is the user AS-1 accepted when it converted the setup's access
// token, the schedule's owner among them; nil for a refusal.
User *User
// Renewal reports that the setup replaced the schedule's stored grant,
// whose setup or renewal record is ReplacedRecord.
Renewal bool
ReplacedRecord string
// Definition is the definition the schedule runs.
Definition DefinitionRef
// Digest is the schedule's digest the setup stores, with its version,
// which a run's open must carry.
Digest ScheduleDigest
// Ceiling is the schedule's ceiling in Ceiling.String's form, Tools its
// tool list in ToolList.String's, and LeftOut the servers of the
// definition's ceiling that listed no real tools at setup, sorted; all
// empty for a refusal.
Ceiling string
Tools string
LeftOut []string
// ListingProvenance marks Ceiling, Tools, and LeftOut, which follow from
// the setup's listing: mecak8s ran it and reported what it found, so
// they are ProvenanceReportedByMecak8s; empty for a refusal.
ListingProvenance SubjectProvenance
// Horizon is the horizon AS-1 granted; zero for a refusal.
Horizon time.Time
// SourceJTI is the converted access token's jti, read without
// verification; empty when it had none or could not be read.
SourceJTI string
}
ScheduleSetupRecord records a schedule's setup or renewal (credentials-and-lifecycle.md, "Schedule setup", "Evidence"): a completed one, accepted before its grant is stored, which a scheduled run's records refer to as the schedule's grant record, or a refused one with its reason. One type covers both, marked by Renewal, so the trail keeps every grant record of a schedule in one stream.
func (*ScheduleSetupRecord) Header ¶ added in v0.0.53
func (r *ScheduleSetupRecord) Header() RecordHeader
Header implements Record.
func (*ScheduleSetupRecord) Subjects ¶ added in v0.0.53
func (r *ScheduleSetupRecord) Subjects() Subjects
Subjects implements Record.
type ScheduleStatus ¶ added in v0.0.53
type ScheduleStatus struct {
ScheduleID string
// Owner is the schedule's recorded owner, the verified owner of its
// grants; zero when it holds none and was neither deleted nor revoked.
Owner Owner
// Ended is the reason the schedule ended, ReasonScheduleEnded after a
// deletion; empty otherwise. An ended schedule holds no grant.
Ended Reason
// Revoked reports that the schedule was revoked without a deletion and
// no setup has completed since: it holds no stored grant, and its runs
// fail with ReasonSetupRequired.
Revoked bool
// Grant is the grant runs use; nil when none. Its horizon may have
// passed: the owner then needs to renew it.
Grant *ScheduleGrantView
// Pending is a setup or renewal in progress; nil when none.
Pending *ScheduleSetup
}
ScheduleStatus is what the broker holds for a schedule. With no Grant, Pending, or Ended, the broker holds nothing for it: it was never set up, or its grants ended without a deletion.
type ScheduleTrigger ¶ added in v0.0.54
type ScheduleTrigger string
ScheduleTrigger is what started a scheduled run.
const ( // ScheduleTriggerTimer is a run its schedule's timer started. ScheduleTriggerTimer ScheduleTrigger = "timer" // ScheduleTriggerManual is a run started by hand, such as a fire-now // request. ScheduleTriggerManual ScheduleTrigger = "manual" )
The triggers of a scheduled run.
type ServerRefusal ¶ added in v0.0.52
ServerRefusal is AS-1's or AS-2's refusal of a token or revocation endpoint request: the HTTP status and, from an RFC 6749 §5.2 error body, the error code and the reason code that starts error_description (design "Error reasons"). Code and Reason are empty when absent and "unknown" when present but not a code the broker knows, so a server cannot place arbitrary text, such as a token, in the error.
func NewServerRefusal ¶ added in v0.0.52
func NewServerRefusal(status int, code, description string) *ServerRefusal
NewServerRefusal returns the refusal for status and a response's error and error_description members, keeping the code and the leading reason code (description "reason" or "reason: text") only when each is known, and nothing else.
func (*ServerRefusal) Error ¶ added in v0.0.52
func (r *ServerRefusal) Error() string
type Service ¶
type Service interface {
// OpenSession opens the broker session for a root host session, or returns
// the one already open for it.
//
// An open naming a schedule (OpenSessionRequest.ScheduleID) opens it from
// the schedule's grant instead of an access token: its stored grant for
// a run, or the pending setup's for the setup's own listing session. The
// host session's open broker session is returned as it is only when the
// same schedule opened it; a session opened from another schedule, or
// for a user, fails with CodeAlreadyExists either way. The checks run in
// order, none calling AS-1:
// - a reported owner that is not the schedule's recorded owner:
// CodePermissionDenied, ReasonOwnerMismatch for a run, and
// ReasonSessionOwned for a setup's session;
// - a deleted schedule: CodeFailedPrecondition, ReasonScheduleEnded;
// - for a run, a schedule revoked without a deletion and not set up
// again since: CodeFailedPrecondition, ReasonSetupRequired;
// - for a run, a schedule holding no stored grant: the session opens
// with none, as an open without an access token does, and its gateway
// calls fail with ReasonNoGrant; for a setup's session, a setup that
// is not pending: CodeFailedPrecondition;
// - for a run, a digest (OpenSessionRequest.Digest) other than the one
// the schedule's setup stored, its version included:
// CodeFailedPrecondition, ReasonSetupRequired; so is a repeated open
// of a run's session with another digest than the one it opened with;
// - a grant past its horizon: CodeFailedPrecondition,
// ReasonSetupRequired.
// The grant is then exchanged at AS-1 for the session's refresh token,
// which ends no later than the horizon, and, for a setup's session, than
// the setup lapses, and is held for the schedule's recorded owner, whom a
// call's run owner must equal. A setup has one listing session, which
// every open of the setup returns while it is open, and which closes once
// the setup is completed, cancelled, replaced, revoked, or lapses; a setup
// that ends during the open's exchange fails it with
// CodeFailedPrecondition. AS-1's revocation
// of the grant fails with ReasonScheduleEnded after a deletion and
// ReasonSetupRequired otherwise, as does a grant AS-1 no longer accepts
// once its horizon has passed; other failures are as for an access token.
// Each refusal by an end of the schedule's authority also names that end
// in Error.ScheduleEnd (horizon reached, schedule changed, revoked at
// AS-1 or at the broker, deleted), which its record carries, since one
// reason covers several of them. A run's open whose
// record is not accepted is tried once more, then fails with
// CodeUnavailable and ReasonRecordNotAccepted.
OpenSession(ctx context.Context, req OpenSessionRequest) (Session, error)
// FindSession returns the open broker session for a root host session, and
// whether one is open. While an open of the host session is creating a
// new broker session, it waits for that open to end, so a find-then-close
// closes the session the open made; a cancelled wait fails with
// CodeUnavailable.
FindSession(ctx context.Context, req FindSessionRequest) (Session, bool, error)
// CloseSession closes a broker session with a closing reason, or a root
// host session's (CloseSessionRequest.RootHostSessionID), without
// waiting for an open in progress. Closing an already closed session
// succeeds and keeps its first reason.
CloseSession(ctx context.Context, req CloseSessionRequest) error
// RegisterAgent registers an agent instance in an open broker session and
// returns its reference and credential.
RegisterAgent(ctx context.Context, req RegisterAgentRequest) (Registration, error)
// AuthorizeCall decides whether the agent presenting the credential may
// make an MCP call, and returns the gateway token when it may. A denial is
// an error, so a caller that ignores the result cannot dispatch.
//
// The checks run in order, each failing as shown:
// - an invalid request: CodeInvalidArgument, recorded naming only the
// calling workload;
// - an unknown session: as for any call;
// - a closed session: its closing reason;
// - a rejection report for an attempt never issued, or already
// reported: CodePermissionDenied, ReasonDenied;
// - a session that holds no refresh token: CodeFailedPrecondition,
// ReasonNoGrant;
// - in a schedule setup's listing session, a call that is not a
// listing: CodePermissionDenied, ReasonDenied; and a listing once the
// setup is no longer pending: CodeFailedPrecondition,
// ReasonSessionClosed, closing the session;
// - a credential that does not verify for the session: as
// VerifyCredential refuses it;
// - a run the broker knows bound to another agent or acting under
// another delegation; a new run naming no delegation from an agent
// that is not a root instance; a run naming a delegation not reported
// for this run and agent; or a run owner that is not the run's owner
// and the grant's owner: CodePermissionDenied, ReasonDenied;
// - a server no gateway routes: CodePermissionDenied, ReasonDenied;
// - a call the acting agent's effective ceiling does not allow (its
// definition's ceiling, narrowed by its parent's when it registered):
// a tool the ceiling excludes, a tool not on a server's list of the
// only tools it allows, or a tool on a server it does not grant, or a
// listing of a server it does not grant, and, in a scheduled run's
// session, such a call the schedule's ceiling does not allow:
// CodePermissionDenied, ReasonDenied, recorded with the ceiling
// checked, the two intersected in a run;
// - in a scheduled run's session, a tools/call of a tool not on the
// schedule's tool list (Session.Tools), from any instance in the run:
// CodePermissionDenied, ReasonDenied.
//
// A call that passes the run checks records a run the broker had not
// seen: as a root run of the acting agent with the reported owner, or, for
// a call naming a reported delegation, as that delegation's run.
//
// Then the broker obtains a fresh gateway token for this call alone,
// failing as shown:
// - the gateway's authorization server not bound, or an authorization
// server or the broker's records unavailable: CodeUnavailable;
// - a reported attempt that does not match the call:
// CodePermissionDenied, ReasonDenied;
// - the session closed during the call: its closing reason;
// - AS-1's svid_expired, denied, signed_out, upstream_revoked, or
// owner_action_required: that reason; its actor_token_expired:
// ReasonSVIDExpired; its approval_required: ReasonDenied;
// - a revoked grant, unless the session holds a newer one:
// ReasonSessionClosed, closing the session;
// - consent the gateway requires: CodeFailedPrecondition,
// ReasonConsentRequired;
// - a user the gateway's authorization server does not know, who has
// never signed in at the gateway: CodeFailedPrecondition,
// ReasonSubjectUnknown; the call is not retried with a new ID-JAG;
// - a gateway token whose response does not carry the call entry the
// broker sent (step (8a)): CodeInternal, ReasonCallEntryMissing when
// the response has none, ReasonCallEntryMismatch when it has another;
// the token is discarded and the call not retried;
// - any other failure: CodeInternal.
AuthorizeCall(ctx context.Context, req AuthorizeCallRequest) (Authorization, error)
// ReportDelegation reports that a run of one agent delegated work to a
// run of another, so the receiving run may make calls. An accepted report
// records the delegation and the receiving run, and records the
// delegating run as a root run when the broker has not seen it.
//
// The checks run in order, each failing as shown:
// - an invalid request: CodeInvalidArgument;
// - an unknown session: as for any call;
// - a closed session: its closing reason;
// - a delegating run bound to another agent, or itself delegated by a
// delegation not reported for it; or, unseen, from an agent that is
// not a root instance registered to the session:
// CodePermissionDenied, ReasonDenied;
// - a stand-in delegating run (StandInDelegatingRun) that is not a root
// run of the session's root agent: CodePermissionDenied, ReasonDenied;
// - a receiving agent not registered to the session:
// CodePermissionDenied, ReasonDenied;
// - an owner that is not the delegating run's owner:
// CodePermissionDenied, ReasonDenied;
// - a delegation already reported with different content, the
// stand-in mark included: CodeAlreadyExists; with the same content
// the report succeeds;
// - a receiving run already recorded: CodePermissionDenied,
// ReasonDenied.
ReportDelegation(ctx context.Context, req ReportDelegationRequest) error
// ReportCall reports what the MCP client observed of one attempt of a
// tools/call the broker authorized: whether it dispatched the call and
// the outcome it observed. The broker records each report as reported
// by mecak8s, joined to the decision that issued the attempt, and never
// waits on its sink for it. A closed session still takes reports of the
// attempts it issued.
//
// Each report is handled as shown:
// - an invalid request, including a dispatch or outcome outside its
// fixed set: CodeInvalidArgument, recorded as a rejected report;
// - an unknown session, an attempt the broker did not issue in the
// session, or one it issued for another operation: recorded as a
// mismatch, not dropped, and accepted;
// - the same report again, joined or recorded as a mismatch: accepted,
// and nothing more is recorded while the broker remembers the first;
// - a different report of an attempt already reported, or a late
// result for an attempt whose outcome was not reported unknown:
// recorded as a mismatch and accepted.
ReportCall(ctx context.Context, req ReportCallRequest) error
// BeginScheduleSetup begins setting up, or renewing, a schedule's grant
// while its owner is present (design "Schedule setup"), converting the
// owner's access token at AS-1 into a grant that issues only refresh
// tokens, until req.Horizon or AS-1's cap, whichever is earlier. The
// grant is held as the schedule's pending setup and is never used for
// runs: a new setup replaces an earlier pending one, recording that
// one's drop as CancelScheduleSetup does, and a schedule's stored grant
// stays in use until a renewal completes. A pending setup lapses after a
// few minutes; a lapse is not recorded.
//
// The checks run in order, each failing as shown, none of them calling
// AS-1, so the token is not spent:
// - an invalid request, or a horizon not later than the clock skew
// from now, which every run's open would count as passed:
// CodeInvalidArgument;
// - an access token whose sub_id, read without verification, is
// missing or not of format iss_sub: CodeUnauthenticated,
// ReasonSubjectInvalid; or not req.Owner: CodePermissionDenied,
// ReasonOwnerMismatch;
// - a schedule recorded for another owner: CodePermissionDenied,
// ReasonSessionOwned; a deleted schedule: CodeFailedPrecondition,
// ReasonScheduleEnded;
// - a definition the broker did not load: CodePermissionDenied;
// - a token AS-1 may already have converted, or is converting, for any
// session or schedule: CodeUnauthenticated, ReasonTokenUsed.
// The exchange then fails as OpenSession's does, and an answer that does
// not match the request or cannot be decoded with CodeInternal; a failed
// setup leaves the schedule as it was. A schedule deleted, or set up by
// another owner, while AS-1 converted the token fails the setup as the
// checks above would. One changed meanwhile is set up with the digest
// req carries, so its runs, whose digest differs, are refused with
// ReasonSetupRequired. A broker that converts no access tokens fails
// every setup with CodeInternal.
BeginScheduleSetup(ctx context.Context, req BeginScheduleSetupRequest) (ScheduleSetup, error)
// CompleteScheduleSetup completes a setup or renewal begun, once its
// listing session has listed the definition's gateway servers. The
// schedule's tool list is the tools in req.ListedTools that the
// definition's ceiling allows, and its ceiling is the definition's
// narrowed to the servers with at least one; the servers it leaves out
// are returned. The setup
// is recorded, as a renewal when the schedule holds a stored grant, and
// only once its record is accepted does the pending grant replace the
// stored one: runs already open keep their own refresh tokens, and new
// runs use the new grant, whose records refer to this record.
//
// It fails as shown, leaving a stored grant in use:
// - an invalid request: CodeInvalidArgument;
// - a schedule recorded for another owner: CodePermissionDenied,
// ReasonSessionOwned; a deleted schedule: CodeFailedPrecondition,
// ReasonScheduleEnded;
// - a setup that is not pending, or that is replaced, cancelled, or
// lapses before it is stored: CodeFailedPrecondition;
// - a record not accepted: CodeUnauthenticated,
// ReasonRecordNotAccepted, and the pending setup is dropped, so the
// client refreshes its access token and sets the schedule up again.
// Once the record is sent, the setup's listing session is closed.
CompleteScheduleSetup(ctx context.Context, req CompleteScheduleSetupRequest) (CompletedScheduleSetup, error)
// CancelScheduleSetup drops a schedule's pending setup and closes its
// listing session, leaving any stored grant in use. Cancelling a setup
// that is not pending succeeds. The drop is recorded, naming the setup
// and the access token its begin converted, without waiting for the
// record.
//
// It takes no owner and checks none: the broker trusts the workload,
// which authorizes its caller against the schedule first, to name it. An
// owner check would let a mis-reported owner keep a grant the workload
// meant to drop, failing open.
CancelScheduleSetup(ctx context.Context, req CancelScheduleSetupRequest) error
// RevokeSchedule drops a schedule's stored grant and pending setup, so
// no new run uses them, and closes the pending setup's listing session;
// runs already open keep their own refresh tokens. A revocation without
// a deletion does not stop a setup whose AS-1 exchange began before it:
// that setup can still complete and store its grant, the owner's last
// action winning.
// For a deleted schedule it also marks the schedule ended, so a setup
// fails with CodeFailedPrecondition and ReasonScheduleEnded. Otherwise it
// marks the schedule revoked, keeping its recorded owner, until a setup
// completes: a run's open fails with CodeFailedPrecondition and
// ReasonSetupRequired, including one whose AS-1 exchange is under way,
// and another owner's setup with ReasonSessionOwned. Revoking
// succeeds whatever the broker holds for the schedule, and is recorded
// without waiting for the record.
//
// Like CancelScheduleSetup, it takes no owner and checks none: the
// workload authorizes its caller against the schedule first, and an
// owner check would let a mis-reported owner keep a deleted schedule's
// grant alive, failing open.
RevokeSchedule(ctx context.Context, req RevokeScheduleRequest) error
// FindSchedule returns what the broker holds for a schedule: its
// recorded owner, stored grant, pending setup, and whether it ended.
// Like every session open and schedule call, it first records each
// schedule grant that reached its horizon since the last such call
// (mecatl_schedule_expired), so a caller that wants that record at the
// horizon itself calls it then.
FindSchedule(ctx context.Context, req FindScheduleRequest) (ScheduleStatus, error)
}
Service is the contract between Mecatl and the identity broker: every call Mecatl makes goes through it, whether the broker runs in process or as its own service. Requests and results are plain values owned by this package, and every error is an *Error carrying a Code and, where the design defines one, a Reason.
Behavior every implementation provides:
- OpenSession for a host session that already has an open broker session returns that session when the incarnation and owner match. A different owner fails with CodePermissionDenied and ReasonSessionOwned; a different incarnation fails with CodeAlreadyExists.
- OpenSession with no access token pairs the broker session with the owner the caller reports, and the session holds no refresh token.
- FindSession finds the open broker session from its root host session.
- A closed broker session is never reopened. It refuses registration and calls with its closing reason, such as ReasonSessionClosed with CodeFailedPrecondition, and a later OpenSession for the same host session opens a new broker session with a new ID.
- RegisterAgent refuses a request whose owner differs from the broker session's owner with CodePermissionDenied: one session tree has one owner. It also refuses, with CodePermissionDenied, an agent with no parent whose host session or incarnation is not the broker session's root host session or incarnation, an agent whose parent is not registered to the session or whose reported parent host session is not the parent's recorded host session, an agent whose stand-in parent (StandInParent) is not the session's root agent, and a new agent whose definition reference is not exactly one the broker loaded. A stand-in parent mark with no parent is CodeInvalidArgument.
- In a session opened from a schedule's grant, RegisterAgent refuses, with CodePermissionDenied, an agent with no parent whose definition's source or name is not the schedule's; its revision is whichever the broker loaded. In a run's session, that agent's effective ceiling is its definition's narrowed to the schedule's ceiling, so a server added after setup stays out until the schedule is renewed; in a setup's session it is the definition's own. An agent registered before, in another session, keeps its effective ceiling when it registers in a run's session; AuthorizeCall holds its calls there to the schedule's ceiling as well.
- Registering the same incarnation again returns the same agent with a fresh credential, so a lost response or an expiring credential is handled by registering again. Registering it into a new broker session moves it there, keeping its identity. A registration of the same incarnation with a different owner, host session, definition reference, parent, or stand-in parent mark fails with CodeAlreadyExists and changes nothing. An agent registering again is not checked against the definitions loaded now: it keeps the definition it registered with.
- A failed registration leaves any earlier registration as it was. A registration that keeps losing a race to other registrations of the same incarnation fails with CodeAborted; registering again succeeds.
- Agents with different incarnations are different agents. An agent's subject is its SPIFFE ID, spiffe://<trust domain>/agent/<ag_ identifier>, which carries no definition name, incarnation, or ancestry; CheckRegistration checks that form, and a caller holding an earlier registration of the incarnation checks the agent is the same.
- A broker session ID the broker never issued is refused with CodePermissionDenied.
- Invalid requests fail with CodeInvalidArgument.
An implementation that converts access tokens at session open (design step (3); Broker with WithAuthServer) also:
- Refuses, without calling AS-1, an access token whose sub_id, read without verification, is not the reported owner, with CodePermissionDenied and ReasonOwnerMismatch, or is missing or not of format iss_sub, with CodeUnauthenticated and ReasonSubjectInvalid; and an open of a session whose verified owner is another user, with ReasonSessionOwned. A broker session has two owners: the one the caller reported, which pairs it, and the verified owner, recorded only when AS-1 first accepts a token for it.
- Exchanges the token at AS-1 for a refresh token the session holds, never past the session's hard expiry, and reports it in Session.HoldsRefreshToken. A token AS-1 may already have converted, for any session, is never presented to AS-1 again: an open repeating it returns the session as it is when the session holds a live refresh token, and fails with ReasonTokenUsed otherwise. AS-1's token_used and its refusal of the token fail with CodeUnauthenticated and ReasonTokenUsed or ReasonSubjectInvalid, after which the client refreshes its access token and opens again; a user-wide revocation fails with ReasonSignedOut, ReasonUpstreamRevoked, or ReasonOwnerActionRequired and the reason's code, after which the user signs in again; an unavailable AS-1 fails with CodeUnavailable, and any other failure with CodeInternal. A failed exchange leaves an existing session paired, with any refresh token it held, and closes one the open created: a refused open never leaves a session. An answer that does not match the request or cannot be decoded closes the session.
- Returns only once the open's record is accepted. Otherwise the open changes nothing and fails with ReasonRecordNotAccepted: with CodeUnauthenticated when it converted the request's token, which is spent, so the client refreshes it before opening again, and CodeUnavailable otherwise. When the session closes while AS-1 converts the token, the open fails with CodeFailedPrecondition and ReasonSessionClosed and the session keeps no refresh token; the token has been spent, so the client refreshes it before opening again.
- Closes a session with ReasonSessionClosed when its refresh token's expiry, the session's hard expiry, passes: from then on every call finds it closed, and the next OpenSession for its host session opens a new broker session.
No request names the calling workload: the broker authenticates it itself, and Mecatl gets a Service from NewInProcess. Implementations provide this behavior by implementing Core.
func NewInProcess ¶
func NewInProcess(authn Authenticator, core Core) Service
NewInProcess returns the Service Mecatl calls when the broker runs in its process. Each call asks authn which workload is calling, then passes it to core, so the in-process path takes the same authentication step as a remote one.
type Session ¶
type Session struct {
// ID is the broker session ID. The broker allocates it and never reuses it.
ID string
HostSessionID string
Incarnation string
// Owner is the owner the caller reported when it opened the session.
Owner Owner
// HoldsRefreshToken reports whether the session held a live refresh token
// when the call returned: while it does, the caller need not send an
// access token. The broker itself never presents a token AS-1 may
// already have converted, for any session, to AS-1 again. The refresh
// token never leaves the broker.
HoldsRefreshToken bool
// ScheduleID is the schedule the session was opened from; empty for a
// session opened for a user. A run's session that holds no refresh token
// opened without a grant, as the schedule held none, and its gateway
// calls fail with ReasonNoGrant.
ScheduleID string
// SetupID is the setup whose listing session this is, not a run's; empty
// otherwise.
SetupID string
// Tools is the tool list of a run's session opened from its schedule's
// stored grant, the only tools any instance in the run may call
// (ScheduleGrantView.Tools); nil for any other session.
Tools *ToolList
}
Session is a broker session.
type SessionCloseRecord ¶ added in v0.0.53
type SessionCloseRecord struct {
RecordHeader
SessionID string
HostSessionID string
ScheduleMark
// Workload is the workload the session belongs to.
Workload Workload
Owner Owner
// ClosingReason is the reason later calls on the session fail with.
ClosingReason Reason
Cause CloseCause
// SessionRecord is the AuditID of the open that created the session: for
// CloseOpenRefused, its refusal. That refusal is queued, so the sink may
// refuse it, or the queue drop it, and the close then names a record the
// trail does not hold (the #2848 shortcut on recordQueue).
SessionRecord string
// UserRecord is the AuditID of the open that verified the session's
// user, and User that user; empty when none did.
UserRecord string
User User
}
SessionCloseRecord records a broker session closing, once per session, from every close path (credentials-and-lifecycle.md step (3), "Session end").
func (*SessionCloseRecord) Header ¶ added in v0.0.53
func (r *SessionCloseRecord) Header() RecordHeader
Header implements Record.
func (*SessionCloseRecord) Subjects ¶ added in v0.0.53
func (r *SessionCloseRecord) Subjects() Subjects
Subjects implements Record.
type SessionOpenRecord ¶ added in v0.0.53
type SessionOpenRecord struct {
RecordHeader
Workload Workload
HostSessionID string
Incarnation string
// ReportedOwner is the owner mecak8s reported.
ReportedOwner Owner
// SessionID is the broker session, when the open reached one.
SessionID string
// NewSession reports that this open created the broker session.
NewSession bool
// SessionRecord is the AuditID of the open that created the session;
// empty when this open did.
SessionRecord string
// Kind is how a successful open treated the access token or the
// schedule's grant; empty for a refusal.
Kind OpenKind
// TokenPresented reports that the request carried an access token.
TokenPresented bool
// SourceJTI is the access token's jti, read without verification; empty
// when the token had none or could not be read.
SourceJTI string
// User is the session's user: the one AS-1 accepted, for OpenConverted,
// or else the one an earlier open verified, whose AuditID is UserRecord.
// In a session opened from a schedule it is the schedule's user and
// UserRecord the schedule's grant record. Nil when no open verified one.
User *User
UserRecord string
// HardExpiry is the session's hard expiry AS-1 granted, for
// OpenConverted and OpenSchedule.
HardExpiry time.Time
// Replaced is the refresh token a converting open replaced; nil when the
// session held none.
Replaced *ReplacedGrant
// Schedule is the schedule an open naming one opened the session from;
// nil for any other open. Facts the broker did not have, such as those
// of a schedule that holds no grant, are zero. A refusal names only the
// schedule and setup IDs, the end of the schedule's authority that
// refused it, and, when it refused a grant the broker held, its Owner and
// GrantRecord.
Schedule *ScheduleConsent
}
SessionOpenRecord records an OpenSession call: a successful open, or a refused one with its reason (credentials-and-lifecycle.md step (3), "Evidence").
func (*SessionOpenRecord) Header ¶ added in v0.0.53
func (r *SessionOpenRecord) Header() RecordHeader
Header implements Record.
func (*SessionOpenRecord) Subjects ¶ added in v0.0.53
func (r *SessionOpenRecord) Subjects() Subjects
Subjects implements Record.
type Subject ¶ added in v0.0.53
type Subject struct {
Value string
Provenance SubjectProvenance
}
Subject is a record's subject and how the record knows it.
type SubjectProvenance ¶ added in v0.0.53
type SubjectProvenance string
SubjectProvenance says how a record knows a subject, as audit.md's mecatl.provenance marks it.
const ( // ProvenanceVerified marks a subject the broker verified, or one AS-1 // accepted in a token the broker presented to it. ProvenanceVerified SubjectProvenance = "verified" // ProvenanceCredentialVerified marks an instance whose credential the // broker verified, though mecak8s reported which instance it is. ProvenanceCredentialVerified SubjectProvenance = "credential-verified" // #nosec G101 -- a provenance mark, not a credential. ProvenanceUnavailable SubjectProvenance = "unavailable" // ProvenanceReportedByMecak8s marks a subject mecak8s reported and the // broker did not verify. ProvenanceReportedByMecak8s SubjectProvenance = "reported:" + ComponentMecak8s )
func ProvenanceFromRecord ¶ added in v0.0.53
func ProvenanceFromRecord(auditID string) SubjectProvenance
ProvenanceFromRecord marks a subject taken from the retained record auditID.
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token is a bearer credential: an AS-1 access token, an agent credential, or a gateway token. Its value is only available through Value; formatting a Token with any verb prints a redacted placeholder.
type TokenExchange ¶ added in v0.0.52
type TokenExchange struct {
// SubjectToken is the user's AS-1 access token, or a schedule grant.
SubjectToken Token
// SubjectTokenType is SubjectToken's RFC 8693 type: empty for an access
// token, TokenTypeRefreshToken for a schedule grant, which AS-1 exchanges
// for a child grant.
SubjectTokenType string
// Grant is the one authorization_details entry the request carries. A
// zero ExpiresAt leaves expires_at out, and AS-1 applies its maximum.
Grant ExchangeGrant
}
TokenExchange is an exchange request for a refresh token: a session open's or a schedule setup's, whose subject is the user's access token, or a schedule's session open, whose subject is the schedule grant.
type TokenExchangeResult ¶ added in v0.0.52
type TokenExchangeResult struct {
// RefreshToken is the issued token, which RFC 8693 returns in
// access_token.
RefreshToken Token
IssuedTokenType string
// Grants are the authorization_details entries AS-1 echoed.
Grants []ExchangeGrant
}
TokenExchangeResult is AS-1's answer to a session-open exchange.
type ToolList ¶ added in v0.0.53
type ToolList struct {
// contains filtered or unexported fields
}
ToolList is a schedule's tool list (credentials-and-lifecycle.md, "Schedule setup"): for each server of the schedule's ceiling, the tools on it, by their name on the server, that setup listed and the ceiling allows. Consent is per tool: in the schedule's runs, every instance, helpers included, may call only these, whatever its ceiling, so a tool a server adds after setup stays out until the owner renews. It is apart from the ceiling, which keeps granting servers whole.
A ToolList is immutable once made. The zero ToolList allows no call.
func NewToolList ¶ added in v0.0.53
func NewToolList(servers ...ToolListServer) ToolList
NewToolList returns the tool list of servers, each with its tools, so a list from Servers can be rebuilt outside the package: NewToolList( l.Servers()...) lists what l does. A server listed twice gets the union of its tools. As in NewCeiling, server names are trimmed and a blank one is ignored, and tool names are kept exactly, an empty one ignored; a server left with no tool is not on the list.
func (ToolList) Allows ¶ added in v0.0.53
Allows reports whether l lists tool, by its name on server.
func (ToolList) Servers ¶ added in v0.0.53
func (l ToolList) Servers() []ToolListServer
Servers returns l's servers, sorted, each with its tools sorted.
func (ToolList) String ¶ added in v0.0.53
String is l in a canonical form for records: one entry per server, sorted and separated as Ceiling.String separates them, each naming its tools, sorted and written as Ceiling.String writes them, as in "github=create_issue,list_issues; jira=get_issue". It is "none" for a list holding no tool.
type ToolListServer ¶ added in v0.0.53
ToolListServer is one server of a tool list with its tools.
type UnverifiedAuthenticator ¶
type UnverifiedAuthenticator struct {
Name string
}
UnverifiedAuthenticator returns the same unverified workload for every call. It stands in until the broker authenticates the workload's credential, which will be addressed later.
func (UnverifiedAuthenticator) Authenticate ¶
func (a UnverifiedAuthenticator) Authenticate(context.Context) (Workload, error)
Authenticate implements Authenticator. The workload is never verified.
type User ¶ added in v0.0.53
User is the user a broker session's refresh token was granted for, as AS-1 accepted their access token: the company identity from its sub_id, AS-1's own issuer and subject, and the client the token was issued to. The broker reads them from the token without verifying it, and keeps them only once AS-1 accepts the token. A claim the token lacks is empty.
type VerifiedAgent ¶
type VerifiedAgent struct {
Agent AgentRef
// AgentID is the agent's opaque ag_ identifier, the last segment of
// ActorID. It never contains a SPIFFE path or definition name.
AgentID string
// ActorID is the agent's name in an ID-JAG's act.sub:
// spiffe://<trust domain>/agent/<AgentID>, in the broker's agent trust
// domain.
ActorID string
// ExpiresAt is when the credential expires.
ExpiresAt time.Time
}
VerifiedAgent is the agent a valid credential identifies.
type VerifyCredentialForOwnerRequest ¶ added in v0.0.52
VerifyCredentialForOwnerRequest asks whether an agent credential is valid for use under a grant of Owner, whichever of the owner's broker sessions the agent is registered to. AS-1's actor-token validator sends it, with Owner read from the grant's sub_id.
type VerifyCredentialRequest ¶
VerifyCredentialRequest asks whether an agent credential is valid for use in a broker session.
func (VerifyCredentialRequest) Validate ¶
func (r VerifyCredentialRequest) Validate() error
Validate reports whether r is well formed. The error is an *Error with CodeInvalidArgument.
type Workload ¶
type Workload struct {
// Name identifies the calling service, such as a Kubernetes
// ServiceAccount.
Name string
// Verified reports that an authenticator verified the workload's
// credential. The zero value is false, so only an authenticator that
// verifies a credential sets it. When false, Name is a claim nobody
// proved: implementations must never treat it as the verified workload of
// the same name, and records must not present it as verified.
Verified bool
// Issuer is the issuer of the credential the authenticator verified,
// such as the cluster's ServiceAccount token issuer; empty when it
// verified none or names none. Records qualify a verified workload by
// it (audit.md, "AuditEvent profile").
Issuer string
}
Workload is the service making a call, as the broker's authenticator determined it. It is never a request field: Mecatl presents no identity of its own, and the broker decides who is calling.
Source Files
¶
- agents.go
- attempts.go
- authorize.go
- boundary.go
- broker.go
- callentry.go
- callreport.go
- ceiling.go
- clientassertion.go
- config.go
- credential.go
- definition.go
- errors.go
- gateway.go
- keys.go
- recorder.go
- recordqueue.go
- records.go
- runs.go
- scheduleexpiry.go
- scheduleopen.go
- schedules.go
- schedulesetup.go
- serverrefusal.go
- service.go
- sessionopen.go
- sessions.go
Directories
¶
| Path | Synopsis |
|---|---|
|
adapter
|
|
|
as1server
Package as1server hosts AS-1, Mecatl's sign-in authorization server, on ToolHive's embedded authorization server.
|
Package as1server hosts AS-1, Mecatl's sign-in authorization server, on ToolHive's embedded authorization server. |
|
as1server/as1servertest
Package as1servertest runs the real AS-1 (package as1server) for tests of the identity broker and the code that wires it: in process, on loopback TLS, with the identityharness IdP as its upstream and the broker's delegate client keyed by a fresh broker key.
|
Package as1servertest runs the real AS-1 (package as1server) for tests of the identity broker and the code that wires it: in process, on loopback TLS, with the identityharness IdP as its upstream and the broker's delegate client keyed by a fresh broker key. |
|
auditsink
Package auditsink is the identity broker's record sink: it writes each broker record as a toolhive-core audit.AuditEvent in Mecatl's AuditEvent profile (docs/drafts/agent-identity/audit.md, "AuditEvent profile") through the toolhive-core audit logger, and reports a record it could not write to the broker, which toolhive-core's logger does not.
|
Package auditsink is the identity broker's record sink: it writes each broker record as a toolhive-core audit.AuditEvent in Mecatl's AuditEvent profile (docs/drafts/agent-identity/audit.md, "AuditEvent profile") through the toolhive-core audit logger, and reports a record it could not write to the broker, which toolhive-core's logger does not. |
|
authserverclient
Package authserverclient is the identity broker's client of the authorization servers AS-1 and AS-2: it calls their token and revocation endpoints, authenticating every request as the OAuth client identitybroker.BrokerClientID with private_key_jwt (RFC 7523), a fresh client assertion each time, and never with a client secret.
|
Package authserverclient is the identity broker's client of the authorization servers AS-1 and AS-2: it calls their token and revocation endpoints, authenticating every request as the OAuth client identitybroker.BrokerClientID with private_key_jwt (RFC 7523), a fresh client assertion each time, and never with a client secret. |
|
brokerconfig
Package brokerconfig reads the identity broker's configuration file, which the broker owns: the agent trust domain, the broker audience, and the paths of its keys, one per role.
|
Package brokerconfig reads the identity broker's configuration file, which the broker owns: the agent trust domain, the broker audience, and the paths of its keys, one per role. |
|
brokerconfig/brokerconfigtest
Package brokerconfigtest writes an identity broker configuration file and its keys into a test's temporary directory, so tests that enable the identity broker start it the way a deployment does, from operator files.
|
Package brokerconfigtest writes an identity broker configuration file and its keys into a test's temporary directory, so tests that enable the identity broker start it the way a deployment does, from operator files. |
|
definitionloader
Package definitionloader loads the agent definitions the identity broker knows: the operator's global definitions and the built-in definitions each Mecatl release ships.
|
Package definitionloader loads the agent definitions the identity broker knows: the operator's global definitions and the built-in definitions each Mecatl release ships. |
|
inprocesshttp
Package inprocesshttp serves HTTP client requests straight from an http.Handler in the same process, without a network listener.
|
Package inprocesshttp serves HTTP client requests straight from an http.Handler in the same process, without a network listener. |
|
Package conformance provides the contract tests every identity broker implementation, an identitybroker.Core and identitybroker.CredentialVerifier, passes.
|
Package conformance provides the contract tests every identity broker implementation, an identitybroker.Core and identitybroker.CredentialVerifier, passes. |
|
Package lineage follows the identity broker's lineage records in an audit trail.
|
Package lineage follows the identity broker's lineage records in an audit trail. |