ident

package
v0.12.13 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Anonymous = NewNullUser("anon", "none", "Guest User", false)

Anonymous is a logged out user

View Source
var ManagerKey = contextKey{"ident.Manger"}

ManagerKey defines the context key for finding the dataloader

Functions

func GetHandlers

func GetHandlers() map[string]Handler

GetHandlers get handlers that are registered

func Register

func Register(name string, fn Handler)

Register a ident handler

func RegisterConfig

func RegisterConfig(name string, config map[string]string)

RegisterConfig for an ident handler

func SetContextIdent

func SetContextIdent(ctx context.Context, s Ident)

SetContextIdent writes ident into context

func WithContext

func WithContext(ctx context.Context, id Ident) context.Context

WithContext wrap the context with a ident manager

Types

type Config

type Config map[string]string

Config key values to pass to an ident handler

func GetConfig

func GetConfig(name string) Config

GetConfig that matches name

type Configs

type Configs map[string]Config

Configs configs for each handler

func GetConfigs

func GetConfigs() Configs

GetConfigs that have been registered

type Handler

type Handler func(r *http.Request) Ident

Handler handler function to read ident from HTTP request

type Ident

type Ident interface {
	GetIdentity() string
	GetAspect() string
	GetDisplay() string

	GetGroups() []string
	GetRoles() []string
	GetMeta() map[string]string

	HasRole(r ...string) bool
	HasGroup(g ...string) bool

	IsActive() bool
}

Ident interface for a logged in user

func GetContextIdent

func GetContextIdent(ctx context.Context) (s Ident)

GetContextIdent returns a user object from session

func GetIdent

func GetIdent(authList string, r *http.Request) Ident

GetIdent read ident from a list of ident handlers

type Manager

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

Manager holds a mutex and ident

func GetManager

func GetManager(id Ident) *Manager

GetManager returns a new context

func (*Manager) GetIdent

func (m *Manager) GetIdent() *Ident

GetIdent from the manager

func (*Manager) SetIdent

func (m *Manager) SetIdent(u Ident)

SetIdent into manager

type NullUser

type NullUser struct {
	Ident  string `json:"ident"`
	Aspect string `json:"aspect"`
	Name   string `json:"name"`
	Active bool   `json:"active"`
}

NullUser implements a null ident

func NewNullUser

func NewNullUser(ident, aspect, name string, active bool) NullUser

NewNullUser creates a null user ident

func (NullUser) GetAspect

func (m NullUser) GetAspect() string

GetAspect returns aspect

func (NullUser) GetDisplay

func (m NullUser) GetDisplay() string

GetDisplay returns display name

func (NullUser) GetGroups

func (m NullUser) GetGroups() []string

GetGroups returns empty list

func (NullUser) GetIdentity

func (m NullUser) GetIdentity() string

GetIdentity returns identity

func (NullUser) GetMeta

func (m NullUser) GetMeta() map[string]string

GetMeta returns empty list

func (NullUser) GetRoles

func (m NullUser) GetRoles() []string

GetRoles returns empty list

func (NullUser) HasGroup

func (m NullUser) HasGroup(g ...string) bool

HasGroup returns true if matches group

func (NullUser) HasRole

func (m NullUser) HasRole(r ...string) bool

HasRole returns true if matches role

func (NullUser) IsActive

func (m NullUser) IsActive() bool

IsActive returns true if active

func (NullUser) MakeHandlerFunc

func (m NullUser) MakeHandlerFunc() func(r *http.Request) Ident

MakeHandlerFunc returns handler func

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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