Versions in this module Expand all Collapse all v1 v1.0.0 Jul 23, 2026 Changes in this version + const ReasonNoMatch + const ReasonRuleMatched + const Wildcard + type CombiningAlgorithm func(ctx context.Context, req Request, rules []Rule, def Effect) Decision + type Decision struct + Effect Effect + Reason string + RuleID string + func AllowOverrides(ctx context.Context, req Request, rules []Rule, def Effect) Decision + func DenyOverrides(ctx context.Context, req Request, rules []Rule, def Effect) Decision + func FirstApplicable(ctx context.Context, req Request, rules []Rule, def Effect) Decision + func (d Decision) Allowed() bool + type Effect uint8 + const Allow + const Deny + func (e Effect) String() string + type Evaluator interface + Decide func(ctx context.Context, req Request) Decision + type MatchFunc func(ctx context.Context, req Request) bool + func ActionIs(a string) MatchFunc + func All(ms ...MatchFunc) MatchFunc + func Any(ms ...MatchFunc) MatchFunc + func ResourceIs(r string) MatchFunc + func SubjectIs(s string) MatchFunc + type Matrix struct + func NewMatrix(id string) *Matrix + func (m *Matrix) Allow(subject, resource, action string) *Matrix + func (m *Matrix) Deny(subject, resource, action string) *Matrix + func (m *Matrix) Eval(_ context.Context, req Request) (Effect, bool) + func (m *Matrix) ID() string + func (m *Matrix) Set(subject, resource, action string, effect Effect) *Matrix + type Option func(*Policy) + func WithCombiner(c CombiningAlgorithm) Option + func WithDefaultEffect(e Effect) Option + func WithLogger(l *slog.Logger) Option + func WithRules(rules ...Rule) Option + type Policy struct + func NewPolicy(opts ...Option) *Policy + func (p *Policy) Add(rules ...Rule) *Policy + func (p *Policy) Decide(ctx context.Context, req Request) Decision + type RBAC struct + func NewRBAC(id string) *RBAC + func (r *RBAC) Assign(subject string, roles ...string) *RBAC + func (r *RBAC) Eval(_ context.Context, req Request) (Effect, bool) + func (r *RBAC) Grant(role, resource, action string) *RBAC + func (r *RBAC) ID() string + type Request struct + Action string + Attributes map[string]any + Resource string + Subject string + func (r Request) Attr(key string) (any, bool) + type Rule interface + Eval func(ctx context.Context, req Request) (effect Effect, matched bool) + ID func() string + func AllowWhen(id string, match MatchFunc) Rule + func DenyWhen(id string, match MatchFunc) Rule + func NewRule(id string, effect Effect, match MatchFunc) Rule