Documentation
¶
Overview ¶
Package user provides an API for users and access management.
Index ¶
- Variables
- func CheckMAC(msg, msgMAC, key []byte) bool
- func MakeMAC(msg, key []byte) ([]byte, error)
- func RandStringRunes(n int) string
- func SetLoginCookie(w http.ResponseWriter, u *User, c *securecookie.SecureCookie, t time.Duration) error
- func SetLogoutCookie(w http.ResponseWriter)
- func Validate(u *User) bool
- func Verify(password string, passwordHash, key []byte) bool
- type Role
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotValid = errors.New("invalid user") ErrWrongPassword = errors.New("wrong password") ErrPasswordMatch = errors.New("passwords do not match") ErrNotFound = errors.New("user not found") )
View Source
var Roles = []Role{ Administrator, Author, Visitor, Expert, }
Roles collects all roles required for a project.
Functions ¶
func CheckMAC ¶
CheckMAC checks the message with a msgMAC using the provided key. Use it for a password check.
func RandStringRunes ¶
RandStringRunes returns a random string with the length of n.
func SetLoginCookie ¶
func SetLoginCookie(w http.ResponseWriter, u *User, c *securecookie.SecureCookie, t time.Duration) error
SetLoginCookie sets a secure cookie.
func SetLogoutCookie ¶
func SetLogoutCookie(w http.ResponseWriter)
SetLogoutCookie partially implements user.Authenticator interface.
Types ¶
type Role ¶
type Role int
Role represents a user's role. It's a mean for access control.
const ( // Administrator is able to modify other users. Administrator Role // Author can enter tne /admin endpoint. Author // Visitor is any other user. Visitor // Expert is an expert in the Infocenter. Expert )
Click to show internal directories.
Click to hide internal directories.