accesscontrol

package
v0.0.0-...-b400081 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: CC0-1.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxKeyGetClaims ctxKey = iota
)

Variables

View Source
var (
	ErrInvalidKeyLength = errors.New("Invalid key size, expected 64 bytes")
	ErrNameNonUnique    = errors.New("Name must be unique")
)
View Source
var (
	ErrNilLoginAcceptHandler = errors.New("Login accept handler (lah) cannot be nil")
	ErrNilRoleGranted        = errors.New("Login accept handler (lah) returned roleGranted=nil and shouldLogin=true, this is incorrect")
)
View Source
var (
	ErrNilPermissionsNeeded  = errors.New("PermissionsNeeded cannot be nil")
	ErrZeroPermissionsNeeded = errors.New("PermissionsNeeded cannot be of length zero because then everyone can access")

	ErrGotNilRole       = errors.New("Got nil role while reading token")
	ErrGettingNilClaims = errors.New("Calling GetClaims when provided claims are nil")
)

Functions

This section is empty.

Types

type Accesscontrol

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

func New

func New(name string, key Key) (*Accesscontrol, error)

New creates new Accesscontrol instance, name must be unique to every New call. Key must be 64 bytes in size, if not ErrInvalidKeyLength is returned. Name must be unique, if not ErrNameNonUnique is returned.

func (*Accesscontrol) NewLogin

func (ac *Accesscontrol) NewLogin(lah LoginAcceptHandler, options ...loginOption) (web.Handler, error)

func (*Accesscontrol) NewVerify

func (ac *Accesscontrol) NewVerify(permissionsNeeded []*role.Permission, options ...verifyOption) (web.Middleware, error)

NewVerify creates new verification midellware, user needs to have all permissions from permissionsNeeded to be allowed.

type GetClaims

type GetClaims func(v interface{}) error

GetClaims runs json.Unmarshal(claimsData, v), so v must be a pointer

type Key

type Key = []byte

type LoginAcceptHandler

type LoginAcceptHandler func(ctx context.Context, r *http.Request) (claims interface{}, roleGranted *role.Role, shouldLogin bool, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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