Documentation
¶
Overview ¶
Package policy evaluates broker authorization rules.
Index ¶
- func FirstValue(values []string) string
- func MatchAll(mode MatchMode, patterns []string, values []string) bool
- func SingletonValues(values map[string]string) map[string][]string
- type AttrSpec
- type Decision
- type DecisionOptions
- type Effect
- type FieldSpec
- type Grant
- type GrantMode
- type GrantPolicy
- type MatchMode
- type OperationSpec
- type Policy
- type Registry
- type Request
- type Rule
- type Target
- type TargetMatcher
- type TargetSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstValue ¶
FirstValue returns the first canonical value or an empty string.
Types ¶
type Decision ¶
type Decision struct {
Effect Effect
Allowed bool
Reason string
MatchedDenyRuleIDs []string
MatchedGrantRuleIDs []string
MatchedAllowRuleIDs []string
MatchedRequestRuleIDs []string
GrantID string
GrantPolicy *GrantPolicy
}
Decision is the result of policy evaluation.
type DecisionOptions ¶
DecisionOptions controls one evaluation.
type Grant ¶
type Grant struct {
ID string
Client string
Operation string
Target Target
Attrs map[string][]string
ExpiresAt time.Time
UsesLeft int
Unlimited bool
}
Grant is an active generated allow rule.
type GrantMode ¶
type GrantMode string
GrantMode identifies the execution shape approved by a request rule.
type GrantPolicy ¶
type GrantPolicy struct {
Mode string `json:"mode"`
DefaultMinutes int `json:"default_minutes"`
MaxMinutes int `json:"max_minutes"`
RequestTTLMinutes int `json:"request_ttl_minutes"`
DefaultMaxUses usebudget.Limit `json:"default_max_uses"`
MaxUses usebudget.Limit `json:"max_uses"`
}
GrantPolicy bounds requestable approval grants.
type MatchMode ¶
type MatchMode string
MatchMode selects how a provider-owned policy field is matched.
const ( // MatchGlob applies path.Match semantics. Wildcards do not cross '/'. MatchGlob MatchMode = "glob" // MatchAnyGlob accepts a value set when any concrete value matches. MatchAnyGlob MatchMode = "any_glob" // MatchPathGlob additionally permits a complete "**" path segment. MatchPathGlob MatchMode = "path_glob" // MatchRecursivePathGlob permits "**" anywhere and lets it cross '/'. MatchRecursivePathGlob MatchMode = "recursive_path_glob" // MatchPathOutsidePrefix accepts paths outside every configured prefix. MatchPathOutsidePrefix MatchMode = "path_outside_prefix" // MatchIntegerMaximum treats policy values as inclusive integer ceilings. MatchIntegerMaximum MatchMode = "integer_maximum" )
type OperationSpec ¶
type OperationSpec struct {
TargetKinds []string
Attrs []string
Grantable bool
GrantMode GrantMode
GrantModes []GrantMode
}
OperationSpec describes one provider operation.
func (OperationSpec) AllowsGrantMode ¶ added in v0.2.0
func (op OperationSpec) AllowsGrantMode(mode GrantMode) bool
AllowsGrantMode reports whether a registered operation supports mode.
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
Policy is a normalized policy document.
type Registry ¶
type Registry struct {
Operations map[string]OperationSpec
Targets map[string]TargetSpec
Attrs map[string]AttrSpec
}
Registry is provider-owned vocabulary for policy validation.
func (Registry) Operation ¶ added in v0.2.0
func (r Registry) Operation(name string) (OperationSpec, bool)
Operation returns a defensive copy of a registered operation.
func (Registry) Validate ¶ added in v0.2.0
Validate checks that a provider registry is internally consistent.
func (Registry) ValidateRequest ¶ added in v0.2.0
ValidateRequest checks a provider-classified request against the registry.
type Rule ¶
type Rule struct {
ID string
Effect Effect
Clients []string
Operations []string
Targets []TargetMatcher
Attrs map[string][]string
GrantPolicy *GrantPolicy
Description string
}
Rule is one normalized policy rule.
type TargetMatcher ¶
TargetMatcher is one target constraint in a rule.
func (*TargetMatcher) UnmarshalJSON ¶
func (t *TargetMatcher) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes arbitrary string or string-array target fields.
type TargetSpec ¶
TargetSpec describes one target kind.