roles

package
v2.0.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

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) *settingsmsg.Setting

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

func (*Manager) FindRoleIDsForUser

func (m *Manager) FindRoleIDsForUser(ctx context.Context, userID string) ([]string, error)

FindRoleIdsForUser returns all roles that are assigned to the supplied userid

func (*Manager) List

func (m *Manager) List(ctx context.Context, roleIDs []string) []*settingsmsg.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 settingssvc.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