Versions in this module Expand all Collapse all v2 v2.1.2 May 9, 2024 v2.1.1 Jun 25, 2023 Changes in this version + const Version + var ErrAllUsersConfirmedAlready = errors.New("All existing users are already confirmed") + var ErrConfirmationCodeExpired = errors.New("The confirmation code is no longer valid") + var ErrCookieEmptyUsername = errors.New("Can't set cookie for empty username") + var ErrCookieGetUsername = errors.New("Could not retrieve the username from browser cookie") + var ErrCookieUserMissing = errors.New("Can't store cookie for non-existsing user") + var ErrInvalidCharacters = errors.New("Only letters, numbers and underscore are allowed in usernames") + var ErrMissingUserAtConfirm = errors.New("The user that is to be confirmed no longer exists") + var ErrOutOfConfirmationCodes = errors.New("Too many generated confirmation codes are not unique") + var ErrUsernameAsPassword = errors.New("Username and password must be different, try another password") + func PermissionDenied(w http.ResponseWriter, req *http.Request) + func ValidUsernamePassword(username, password string) error + type Permissions struct + func New() (*Permissions, error) + func NewPermissions(state *UserState) *Permissions + func NewWithConf(connectionString string) (*Permissions, error) + func NewWithDSN(connectionString string, database_name string) (*Permissions, error) + func (perm *Permissions) AddAdminPath(prefix string) + func (perm *Permissions) AddPublicPath(prefix string) + func (perm *Permissions) AddUserPath(prefix string) + func (perm *Permissions) Clear() + func (perm *Permissions) DenyFunction() http.HandlerFunc + func (perm *Permissions) Rejected(w http.ResponseWriter, req *http.Request) bool + func (perm *Permissions) ServeHTTP(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) + func (perm *Permissions) SetAdminPath(pathPrefixes []string) + func (perm *Permissions) SetDenyFunction(f http.HandlerFunc) + func (perm *Permissions) SetPublicPath(pathPrefixes []string) + func (perm *Permissions) SetUserPath(pathPrefixes []string) + func (perm *Permissions) UserState() pinterface.IUserState + type UserState struct + func NewUserState(connectionString string, randomseed bool) (*UserState, error) + func NewUserStateSimple() (*UserState, error) + func NewUserStateWithDSN(connectionString string, database_name string, randomseed bool) (*UserState, error) + func (state *UserState) AddUnconfirmed(username, confirmationCode string) + func (state *UserState) AddUser(username, password, email string) + func (state *UserState) AdminRights(req *http.Request) bool + func (state *UserState) AllUnconfirmedUsernames() ([]string, error) + func (state *UserState) AllUsernames() ([]string, error) + func (state *UserState) AlreadyHasConfirmationCode(confirmationCode string) bool + func (state *UserState) BooleanField(username, fieldname string) bool + func (state *UserState) ClearCookie(w http.ResponseWriter) + func (state *UserState) Close() + func (state *UserState) Confirm(username string) + func (state *UserState) ConfirmUserByConfirmationCode(confirmationcode string) error + func (state *UserState) ConfirmationCode(username string) (string, error) + func (state *UserState) CookieSecret() string + func (state *UserState) CookieTimeout(username string) int64 + func (state *UserState) CorrectPassword(username, password string) bool + func (state *UserState) Creator() pinterface.ICreator + func (state *UserState) Email(username string) (string, error) + func (state *UserState) FindUserByConfirmationCode(confirmationcode string) (string, error) + func (state *UserState) GenerateUniqueConfirmationCode() (string, error) + func (state *UserState) HasUser(username string) bool + func (state *UserState) HashPassword(username, password string) string + func (state *UserState) Host() pinterface.IHost + func (state *UserState) IsAdmin(username string) bool + func (state *UserState) IsConfirmed(username string) bool + func (state *UserState) IsLoggedIn(username string) bool + func (state *UserState) Login(w http.ResponseWriter, username string) error + func (state *UserState) Logout(username string) + func (state *UserState) MarkConfirmed(username string) + func (state *UserState) PasswordAlgo() string + func (state *UserState) PasswordHash(username string) (string, error) + func (state *UserState) RemoveAdminStatus(username string) + func (state *UserState) RemoveUnconfirmed(username string) + func (state *UserState) RemoveUser(username string) + func (state *UserState) SetAdminStatus(username string) + func (state *UserState) SetBooleanField(username, fieldname string, val bool) + func (state *UserState) SetCookieSecret(cookieSecret string) + func (state *UserState) SetCookieTimeout(cookieTime int64) + func (state *UserState) SetLoggedIn(username string) + func (state *UserState) SetLoggedOut(username string) + func (state *UserState) SetMinimumConfirmationCodeLength(length int) + func (state *UserState) SetPassword(username, password string) + func (state *UserState) SetPasswordAlgo(algorithm string) error + func (state *UserState) SetUsernameCookie(w http.ResponseWriter, username string) error + func (state *UserState) UserRights(req *http.Request) bool + func (state *UserState) Username(req *http.Request) string + func (state *UserState) UsernameCookie(req *http.Request) (string, error) + func (state *UserState) Users() pinterface.IHashMap Other modules containing this package github.com/xyproto/permissionsql