authorizer

package
v0.0.0-...-9ca37e5 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAdmin

func IsAdmin(format string, v ...interface{}) isAdmin

IsAdmin creates a new condition

func IsAuthenticated

func IsAuthenticated(format string, v ...interface{}) isAuthenticated

IsAuthenticated creates a new condition

func IsAuthorizationError

func IsAuthorizationError(err error) bool

IsAuthorizationError returns true if the given error represents an authorization error and originates from an authorizer module

func IsNotResourceOwner

func IsNotResourceOwner(
	resourceOwner api.Identifier,
	format string,
	v ...interface{},
) isNotResourceOwner

IsNotResourceOwner creates a new condition

func IsResourceOwner

func IsResourceOwner(
	resourceOwner api.Identifier,
	format string,
	v ...interface{},
) isResourceOwner

IsResourceOwner creates a new condition

func IsUser

func IsUser(format string, v ...interface{}) isUser

IsUser creates a new condition

Types

type AuthorizationError

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

AuthorizationError represents an authorization error

func Errorf

func Errorf(format string, v ...interface{}) AuthorizationError

Errorf creates a new formatted validator error

func (AuthorizationError) Error

func (err AuthorizationError) Error() string

Error implements the standard Go error interface

type Authorizer

type Authorizer interface {
	// MeetsAll returns an error if either of the given conditions don't apply.
	// If all of the given conditions apply collectively then nil is returned
	MeetsAll(
		sessionInfo *sessinfo.SessionInfo,
		conditions ...Condition,
	) error

	// MeetsEitherOf returns an error if all of the given conditions
	// don't apply.
	// If at least one of the given conditions applies then nil is returned
	MeetsEitherOf(
		sessionInfo *sessinfo.SessionInfo,
		conditions ...Condition,
	) error
}

Authorizer defines the interface of the authorizer module

func New

func New() Authorizer

New creates a new authorizer module instance

type Condition

type Condition interface {
	Validate(sessionInfo *sessinfo.SessionInfo) error
}

Condition represents an authorization condition interface

Jump to

Keyboard shortcuts

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