embedded

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package embedded implements the default, SPIFFE-shaped JWT-SVID identity provider satisfying identity.Provider. It mints short-lived ES256 JWTs whose subject path is spiffe://<trust-domain>/agent-run/<run-id>, carrying the full delegation chain (human sub, agent-run act, sponsor) for attribution.

INVARIANT (Confinement gating): this provider REFUSES to mint identities for runs whose grants include types.GrantCloudSTS — cloud STS federation hard-requires the spire provider. Callers MUST invoke CheckGrants before mint; ErrRequiresSPIRE is the typed refusal.

All security decisions fail closed: signature, expiry, audience, and revocation are each independently verified, and any RevocationStore error is treated as revoked.

Index

Constants

View Source
const (

	// DefaultTrustDomain is used when New is given an empty trust domain.
	DefaultTrustDomain = "wardyn.local"
)

Variables

View Source
var ErrRequiresSPIRE = errors.New("embedded identity: cloud_sts grant requires the spire identity provider")

ErrRequiresSPIRE is the typed refusal returned by CheckGrants (and MintRunIdentity) when a run's grants include types.GrantCloudSTS. cloud_sts hard-requires the spire provider; the embedded provider must never mint for it.

Functions

This section is empty.

Types

type MemRevocationStore

type MemRevocationStore struct {
	// contains filtered or unexported fields
}

MemRevocationStore is an in-memory RevocationStore for tests.

func NewMemRevocationStore

func NewMemRevocationStore() *MemRevocationStore

func (*MemRevocationStore) IsRevoked

func (m *MemRevocationStore) IsRevoked(_ context.Context, jti string, runID uuid.UUID) (bool, error)

func (*MemRevocationStore) RevokeJTI

func (m *MemRevocationStore) RevokeJTI(_ context.Context, jti string, runID uuid.UUID) error

func (*MemRevocationStore) RevokeRun

func (m *MemRevocationStore) RevokeRun(_ context.Context, runID uuid.UUID) error

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider is the embedded JWT-SVID identity.Provider.

func New

func New(signKey *ecdsa.PrivateKey, trustDomain string, revocations RevocationStore, rec audit.Recorder) (*Provider, error)

New constructs the embedded provider. If signKey is nil a fresh ECDSA P-256 key is generated. trustDomain may be empty (defaults to DefaultTrustDomain). The RevocationStore and audit.Recorder are required.

func (*Provider) CheckGrants

func (p *Provider) CheckGrants(grants []types.GrantSpec) error

CheckGrants returns ErrRequiresSPIRE if any grant requires the spire provider (currently: cloud_sts). The broker/API MUST call this before mint.

func (*Provider) MintRunIdentity

func (p *Provider) MintRunIdentity(ctx context.Context, runID uuid.UUID, humanSub, sponsor, audience string) (identity.RunIdentity, error)

MintRunIdentity issues a 1h ES256 JWT-SVID for runID. humanSub is the human principal; sponsor is the accountable owner (defaults to humanSub when empty); audience binds the token (RFC 8707). It emits an identity.mint audit event (actor_type system).

func (*Provider) Name

func (p *Provider) Name() string

Name reports the provider kind for UI/audit. Always "embedded".

func (*Provider) RevokeRun

func (p *Provider) RevokeRun(ctx context.Context, runID uuid.UUID) error

RevokeRun invalidates ALL identities for a run (kill-switch cascade) and emits an identity.revoke audit event (actor_type system).

func (*Provider) Verify

func (p *Provider) Verify(ctx context.Context, token, expectedAudience string) (*identity.Claims, error)

Verify authenticates a presented token and returns its claims. It validates, independently and failing closed: ES256 signature, expiry/nbf, audience, and revocation. A RevocationStore error is treated as revoked.

type RevocationStore

type RevocationStore = identity.RevocationStore

RevocationStore is the embedded provider's revocation contract. It aliases identity.RevocationStore (the generic kill-switch denylist) so the identity seam's Deps can carry it without importing this package. The pg-backed implementation lives in the control plane; MemRevocationStore (below) is the in-memory one for tests. All reads fail closed at the call site (Verify treats any IsRevoked error as revoked).

Jump to

Keyboard shortcuts

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