Documentation
¶
Overview ¶
Package policy implements server-enforced API-key spending admissions.
Index ¶
- Variables
- func Allowed(list []string, id string) bool
- func Apply(a *model.PolicyAdmission, t *model.Transaction)
- func Integer(s string) (*big.Int, error)
- func Internal(ctx context.Context) context.Context
- func Intersect(key string, policies []model.KeyPolicy) *model.KeyPolicy
- func IsInternal(ctx context.Context) bool
- func RuleKey(currency string, precision float64) string
- func Validate(p model.KeyPolicy) error
- func ValidateNarrowing(child model.KeyPolicy, parent *model.KeyPolicy) error
- func WithPrincipal(ctx context.Context, p Principal) context.Context
- type Engine
- type Principal
- type Store
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrApprovalRequired = errors.New("transaction requires an independent approval decision")
View Source
var ErrDenied = errors.New("spending policy denied transaction")
View Source
var ErrIdentityConflict = errors.New("policy idempotency identity already has different transaction details")
Functions ¶
func Apply ¶
func Apply(a *model.PolicyAdmission, t *model.Transaction)
func Intersect ¶
Intersect keeps only currencies and destinations permitted by every ancestor. Empty configured allowlists mean unrestricted; an empty intersection denies all.
func IsInternal ¶
func ValidateNarrowing ¶
ValidateNarrowing rejects a local child policy that claims any permission broader than its ancestors. An absent child policy inherits them unchanged.
Types ¶
type Principal ¶
func FromContext ¶
func (Principal) CanApprove ¶
func (Principal) CanManagePolicies ¶
type Store ¶
type Store interface {
GetKeyPolicy(context.Context, string) (*model.KeyPolicy, error)
PutKeyPolicy(context.Context, model.KeyPolicy) (*model.KeyPolicy, error)
DeleteKeyPolicy(context.Context, string) error
AdmitPolicy(context.Context, string, string, []model.PolicyLeg) (*model.PolicyAdmission, error)
VerifyPolicyLeg(context.Context, *model.Transaction) (*model.PolicyAdmission, error)
CheckPolicyCommit(context.Context, string) error
ReleasePolicyLeg(context.Context, string) error
ListPolicyApprovals(context.Context, string) ([]model.PolicyAdmission, error)
DecidePolicyApproval(context.Context, string, Principal, bool) (*model.PolicyAdmission, error)
PolicyCapacity(context.Context, string) ([]model.PolicyCapacity, error)
PolicyHoldIDs(context.Context, string) ([]string, error)
}
Click to show internal directories.
Click to hide internal directories.