session

package
v0.12.17 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSession

func CheckSession(r *http.Request) ident.Ident

CheckSession is called by ident to lookup the user

func Config

func Config()

Config sets up the session module

func DeleteSession

func DeleteSession(id string)

DeleteSession removes the session

func GetSessionID

func GetSessionID(id string) ident.Ident

GetSessionID returns a user ident from cache

func NewSession

func NewSession(ident, aspect, display string, groups []string, roles []string, meta map[string]string) ident.Ident

NewSession creates a new session and returns an ident.Ident

Types

type User

type User struct {
	Ident  string              `json:"ident"`
	Aspect string              `json:"aspect"`
	Name   string              `json:"name"`
	Active bool                `json:"active"`
	Groups map[string]struct{} `json:"groups"`
	Roles  map[string]struct{} `json:"roles"`
	Meta   map[string]string   `json:"meta"`
}

User is an ident.Ident

func (User) GetAspect

func (u User) GetAspect() string

GetAspect returns the current aspect of user

func (User) GetCookie

func (u User) GetCookie() *http.Cookie

GetCookie returns a formated cookie value

func (User) GetDisplay

func (u User) GetDisplay() string

GetDisplay returns the display name of user

func (User) GetGroups

func (u User) GetGroups() []string

GetGroups returns list of groups

func (User) GetIdentity

func (u User) GetIdentity() string

GetIdentity returns the identity of user

func (User) GetMeta

func (u User) GetMeta() map[string]string

GetMeta returns additional meta info for user

func (User) GetRoles

func (u User) GetRoles() []string

GetRoles returns list of roles

func (User) HasGroup

func (u User) HasGroup(g ...string) bool

HasGroup returns true if any groups match

func (User) HasRole

func (u User) HasRole(r ...string) bool

HasRole returns true if any roles match

func (User) IsActive

func (u User) IsActive() bool

IsActive returns true if user is active

Jump to

Keyboard shortcuts

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