Versions in this module Expand all Collapse all v1 v1.1.0 Sep 9, 2026 Changes in this version + type BeginInstrumenter interface + Begin func(context.Context) (context.Context, func(Event)) type Instrumented + func NewInstrumentedWithBegin(authorizer Authorizer, instrumenter BeginInstrumenter, ...) (*Instrumented, error) v1.0.0 Aug 26, 2026 Changes in this version + var ErrBatchLimitExceeded = errors.New("authorization batch limit exceeded") + var ErrDuplicatePolicy = errors.New("duplicate policy") + var ErrInvalidActivationWindow = errors.New("invalid policy activation window") + var ErrInvalidCombiningAlgorithm = errors.New("invalid combining algorithm") + var ErrInvalidFloat = errors.New("attribute float must be finite") + var ErrInvalidInstrumentationConfig = errors.New("authorization instrumentation config is invalid") + var ErrInvalidOutcome = errors.New("invalid decision outcome") + var ErrInvalidPolicy = errors.New("invalid policy") + var ErrInvalidRequest = errors.New("invalid authorization request") + var ErrInvalidRevision = errors.New("invalid policy revision") + var ErrNilAuthorizer = errors.New("authorization instrumented authorizer is nil") + var ErrNilInstrumenter = errors.New("authorization instrumenter is nil") + var ErrNilSnapshot = errors.New("authorization snapshot is nil") + var ErrPolicyLimitExceeded = errors.New("authorization policy limit exceeded") + var ErrPolicyPanic = errors.New("authorization policy panicked") + var ErrRevisionConflict = errors.New("authorization revision conflict") + var ErrRevisionNotMonotonic = errors.New("authorization revision is not monotonic") + type Action string + type AttributeName string + type Attributes map[AttributeName]Value + type Authorizer interface + Decide func(context.Context, Request) (Decision, error) + type CombiningAlgorithm uint8 + const AllowOverrides + const DenyOverrides + const FirstApplicable + const PriorityOrder + func (algorithm CombiningAlgorithm) String() string + type Decision struct + MatchedPolicyIDs []PolicyID + MatchedPolicyIDsTruncated bool + Outcome Outcome + Reason ReasonCode + Revision Revision + Trace []TraceEntry + TraceTruncated bool + func Combine(algorithm CombiningAlgorithm, decisions []Decision) (Decision, error) + type Engine struct + func NewEngine(snapshot *Snapshot, options ...EngineOption) (*Engine, error) + func (engine *Engine) Decide(ctx context.Context, request Request) (Decision, error) + func (engine *Engine) DecideBatch(ctx context.Context, requests []Request) ([]Decision, error) + func (engine *Engine) ReplaceSnapshot(next *Snapshot, expected Revision) error + func (engine *Engine) Revision() Revision + type EngineOption func(*Engine) + func WithClock(clock func() time.Time) EngineOption + func WithLimits(limits Limits) EngineOption + type Environment struct + Attributes Attributes + Time time.Time + type Evaluator interface + Evaluate func(context.Context, Request) (Decision, error) + type Event struct + Duration time.Duration + Failed bool + MatchedPolicyIDs []PolicyID + MatchedPolicyIDsTruncated bool + Outcome Outcome + Reason ReasonCode + Revision Revision + TraceCount int + TraceTruncated bool + type InstrumentationConfig struct + Clock func() time.Time + MaxPolicyIDs int + type Instrumented struct + func NewInstrumented(authorizer Authorizer, instrumenter Instrumenter, config InstrumentationConfig) (*Instrumented, error) + func (instrumented *Instrumented) Decide(ctx context.Context, request Request) (Decision, error) + type Instrumenter interface + Start func(context.Context) (context.Context, func(Event)) + type Limits struct + MaxBatchSize int + MaxMatchedPolicyIDs int + MaxPolicies int + MaxTraceSize int + type Outcome uint8 + const Allow + const Deny + const NotApplicable + func (outcome Outcome) String() string + type PolicyDefinition struct + ActiveFrom time.Time + ActiveUntil time.Time + Evaluator Evaluator + ID PolicyID + Metadata map[string]string + Priority int + Revision Revision + type PolicyEvaluationError struct + Err error + PolicyID PolicyID + func (evaluationError *PolicyEvaluationError) Error() string + func (evaluationError *PolicyEvaluationError) Unwrap() error + type PolicyID string + type PolicyInfo struct + ActiveFrom time.Time + ActiveUntil time.Time + ID PolicyID + Metadata map[string]string + Priority int + Revision Revision + type ReasonCode string + const ReasonContextCanceled + const ReasonDefaultDeny + const ReasonEvaluationError + const ReasonInvalidRequest + const ReasonPolicyInactive + const ReasonPolicyStale + type Request struct + Action Action + Attributes Attributes + Environment Environment + Resource Resource + Subject Subject + Tenant TenantID + func (request Request) Validate() error + type Resource struct + Attributes Attributes + ID ResourceID + Type ResourceType + type ResourceID string + type ResourceType string + type Revision uint64 + type Snapshot struct + func NewSnapshot(revision Revision, algorithm CombiningAlgorithm, ...) (*Snapshot, error) + func (snapshot *Snapshot) Algorithm() CombiningAlgorithm + func (snapshot *Snapshot) Policies() []PolicyInfo + func (snapshot *Snapshot) Revision() Revision + type Subject struct + Attributes Attributes + Groups []SubjectID + ID SubjectID + Kind SubjectKind + type SubjectID string + type SubjectKind string + const SubjectAPIKey + const SubjectGroup + const SubjectServiceAccount + const SubjectUser + type TenantID string + type TraceEntry struct + Outcome Outcome + PolicyID PolicyID + Reason ReasonCode + type ValidationError struct + Field string + func (validationError *ValidationError) Error() string + func (validationError *ValidationError) Unwrap() error + type Value struct + func BoolValue(value bool) Value + func FloatValue(value float64) (Value, error) + func IPValue(value netip.Addr) Value + func IntValue(value int64) Value + func MustFloatValue(value float64) Value + func NullValue() Value + func StringSetValue(values []string) Value + func StringValue(value string) Value + func TimeValue(value time.Time) Value + func (value Value) Bool() (bool, bool) + func (value Value) CollectionLength() (int, bool) + func (value Value) Compare(other Value) (int, bool) + func (value Value) Equal(other Value) bool + func (value Value) Float() (float64, bool) + func (value Value) IP() (netip.Addr, bool) + func (value Value) Int() (int64, bool) + func (value Value) Kind() ValueKind + func (value Value) String() (string, bool) + func (value Value) StringSet() ([]string, bool) + func (value Value) Time() (time.Time, bool) + type ValueKind uint8 + const ValueBool + const ValueFloat + const ValueIP + const ValueInt + const ValueMissing + const ValueNull + const ValueString + const ValueStringSet + const ValueTime