authorization

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package authorization coordinates policy decisions and durable approval requests.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDenied              = errors.New("authorization denied")
	ErrNoMatch             = errors.New("authorization has no matching policy rule")
	ErrInvalidGrantIntent  = errors.New("invalid grant intent")
	ErrApprovalUnsupported = errors.New("operation does not support the requested approval mode")
)

Functions

This section is empty.

Types

type ActiveGrantsFunc

type ActiveGrantsFunc func(policy.Request) ([]policy.Grant, error)

ActiveGrantsFunc projects durable grants relevant to request into policy grants.

type Coordinator

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

Coordinator owns the provider-neutral authorize-or-request transition.

func New

func New(options Options) (*Coordinator, error)

New constructs a coordinator over a validated provider registry.

func (*Coordinator) Authorize

func (c *Coordinator) Authorize(request policy.Request, build IntentBuilder) (Result, error)

Authorize allows, refuses, or durably creates an approval request.

func (*Coordinator) RequestApproval

func (c *Coordinator) RequestApproval(request policy.Request, build IntentBuilder) (Result, error)

RequestApproval explicitly requests a bounded approval even when an existing grant could currently authorize the same capability.

type DecideFunc

DecideFunc evaluates one provider-classified request.

type GrantIntent

type GrantIntent struct {
	Mode          policy.GrantMode
	Authorization policy.Request
	Request       grants.Request
	Plan          grants.ImmutablePlan
}

GrantIntent is a provider-built canonical approval request and immutable plan.

type IntentBuilder

type IntentBuilder func(policy.Decision) (GrantIntent, error)

IntentBuilder resolves provider defaults and builds an immutable request after the coordinator has selected the request rule and its bounds.

type Options

type Options struct {
	Registry policy.Registry
	Decide   DecideFunc
	Grants   *grants.Store
	// ActiveGrants projects durable provider grants into policy grants. It
	// defaults to Grants.ActivePolicyGrants when provider-native storage already
	// uses the policy target schema.
	ActiveGrants ActiveGrantsFunc
	Now          func() time.Time
}

Options configures a Coordinator.

type Result

type Result struct {
	Decision policy.Decision
	Request  grants.RequestResult
	Created  bool
}

Result is one authorization decision and optional durable approval request.

Jump to

Keyboard shortcuts

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