Documentation
¶
Index ¶
- Constants
- Variables
- func GetJWTKey() []byte
- func HasPerms(u User, permIds ...string) bool
- func HasRole(u User, role Role) bool
- type AuthData
- type Authenticator
- type Group
- type PermissionNode
- type PermissionSet
- type PermissionTree
- type Role
- type User
- type UserAndPassword
- type UserAuthenticator
- type UserGetter
- type UserRetriever
Constants ¶
View Source
const (
UserSessionTimeout = time.Hour * 24 * 10 // 10 days
)
Variables ¶
View Source
var ( ErrAuthentication = errors.New("auth.user.authenticationError") ErrUserRetrieval = errors.New("auth.user.retrievalError") ErrToken = errors.New("auth.user.authTokenError") ErrInsufficientPrivileges = errors.New("auth.user.insufficient.privs") )
View Source
var ValidRoles = []Role{ Normal, Admin, Super, }
Functions ¶
Types ¶
type Authenticator ¶
type PermissionNode ¶
type PermissionNode struct {
Id int `json:"id" db:"id"`
PermId string `json:"permId" db:"permId"`
Name string `json:"name" db:"name"`
Predefined bool `json:"predefined" db:"predefined"`
// Base string `json:"base" db:"base"`
Children []*PermissionNode `json:"children"`
}
func (*PermissionNode) AddChild ¶
func (pn *PermissionNode) AddChild(child *PermissionNode)
type PermissionSet ¶
type PermissionSet map[string]struct{}
func MergePerms ¶
func MergePerms(permSets []PermissionSet) PermissionSet
func (PermissionSet) HasPerm ¶
func (pm PermissionSet) HasPerm(permId string) bool
type PermissionTree ¶
type PermissionTree struct {
Permissions []*PermissionNode `json:"permissions"`
}
type User ¶
type User interface {
Id() int64
Username() string
Email() string
FullName() string
Role() Role
GroupIds() []string
Permissions() PermissionSet
}
type UserAndPassword ¶
type UserAuthenticator ¶
type UserAuthenticator interface {
Authenticator
UserGetter
}
type UserGetter ¶
Click to show internal directories.
Click to hide internal directories.