roles

package
v0.0.0-...-499b85e Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2021 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadRoleIDsFromContext

func ReadRoleIDsFromContext(ctx context.Context) (roleIDs []string, ok bool)

ReadRoleIDsFromContext extracts roleIDs from the metadata context and returns them as []string

Types

type Manager

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

Manager manages a cache of roles by fetching unknown roles from the settings.RoleService.

func NewManager

func NewManager(o ...Option) Manager

NewManager returns a new instance of Manager.

func (*Manager) FindPermissionByID

func (m *Manager) FindPermissionByID(ctx context.Context, roleIDs []string, permissionID string) *settings.Setting

FindPermissionByID searches for a permission-setting by the permissionID, but limited to the given roleIDs

func (*Manager) List

func (m *Manager) List(ctx context.Context, roleIDs []string) []*settings.Bundle

List returns all roles that match the given roleIDs.

type Option

type Option func(*Options)

Option mutates option

func CacheSize

func CacheSize(s int) Option

CacheSize configures the size of the cache in items.

func CacheTTL

func CacheTTL(ttl time.Duration) Option

CacheTTL rebuilds the cache after the configured duration.

func Logger

func Logger(logger log.Logger) Option

Logger sets a preconfigured logger

func RoleService

func RoleService(rs settings.RoleService) Option

RoleService provides endpoints for fetching roles.

type Options

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

Options are all the possible options.

Jump to

Keyboard shortcuts

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