Documentation
¶
Overview ¶
Package action decodes the actions a policy returns. A policy's result is {"actions": [...]}, and each action is a name such as "signup.allow", or an object with an "action" name and the action's parameters:
{"actions": ["signup.allow", {"action": "signup.deny", "reason": "..."}]}
Names are "<resource>.<verb>". Each hook decides which actions it accepts, what they mean together, and in which order they run.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrV0Result = errors.New(`policy result uses the v0 shape ({"action": ...}): return {"actions": [...]} instead (see docs/upgrading-to-v1.md)`)
ErrV0Result is returned for a result in the v0 shape.
Functions ¶
Types ¶
type Action ¶
type Action struct {
// Name is the action's name, lowercased, such as "signup.deny".
Name string
// contains filtered or unexported fields
}
Action is one action from a policy result.
func (Action) Decode ¶
Decode decodes the action's parameters into v, a pointer to a struct. Unknown parameters are errors, so a misspelled one isn't ignored; pass a pointer to an empty struct for an action that takes none.
func (Action) MarshalJSON ¶
MarshalJSON writes the action the way the policy returned it.
func (*Action) UnmarshalJSON ¶
UnmarshalJSON accepts a name or an object with an "action" name.
type Result ¶
type Result struct {
Actions []Action `json:"actions"`
// V0Action is the top-level "action" of v0 results, decoded only to
// report a helpful error.
V0Action json.RawMessage `json:"action,omitempty"`
}
Result is a policy's result document.