Documentation
¶
Overview ¶
Package accessapikey checks plugin/apikey's key permissions with a plugin/access access control, so the statements an app already declared for its roles are the vocabulary of its API keys too:
apikey.New(apikey.WithPermissions(accessapikey.New(ac)))
Without it the apikey plugin uses its built-in apikey.Vocabulary, which answers identically for the same statements.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker is an apikey.PermissionChecker over an access control. It holds the control by pointer, which is immutable once built, so it is safe for concurrent use.
func New ¶
func New(ac *access.AccessControl) Checker
New adapts ac. A nil ac checks nothing and grants nothing: Check refuses every permission with access.ErrEmptyStatements, so a key cannot be given any.
func (Checker) Check ¶
func (c Checker) Check(p apikey.Permissions) error
Check is ac.Check: a permission naming an undeclared resource or action is access.ErrUnknownResource or access.ErrUnknownAction.
func (Checker) Grants ¶
func (c Checker) Grants(held, want apikey.Permissions) bool
Grants reports whether held authorizes want: every action of every resource of want must be in held. A held resource or action the statements no longer declare (one removed after the key was made) is skipped rather than refusing the whole role, as apikey.Vocabulary.Grants does, so the key's other permissions keep their answer; the stale one grants nothing, because a role without it cannot allow it.