Documentation ¶
Overview ¶
Package store implements a simple storage backend for whawty.auth password hash files. The schema of the whawty.auth password store can be found in the doc directory. If the environment contains the variable WHAWTY_AUTH_DEBUG logging will be enabled. By default whawty.auth doesn't log anything.
Index ¶
- type Argon2IDHasher
- type Argon2IDParams
- type Dir
- func (d *Dir) AddUser(user, password string, isAdmin bool) (err error)
- func (d *Dir) Authenticate(user, password string) (isAuthenticated, isAdmin, upgradeable bool, lastchange time.Time, err error)
- func (d *Dir) Check() error
- func (d *Dir) Exists(user string) (exists bool, isAdmin bool, err error)
- func (d *Dir) Init(admin, password string) error
- func (d *Dir) List() (UserList, error)
- func (d *Dir) ListFull() (UserListFull, error)
- func (d *Dir) RemoveUser(user string)
- func (d *Dir) SetAdmin(user string, adminState bool) (err error)
- func (d *Dir) UpdateUser(user, password string) (err error)
- type Hasher
- type ScryptAuthHasher
- type ScryptAuthParams
- type User
- type UserFull
- type UserHash
- func (u *UserHash) Add(password string, isAdmin bool) error
- func (u *UserHash) Authenticate(password string) (isAuthenticated, isAdmin, upgradeable bool, lastchange time.Time, err error)
- func (u *UserHash) Exists() (exists bool, isAdmin bool, err error)
- func (u *UserHash) Remove()
- func (u *UserHash) SetAdmin(adminState bool) error
- func (u *UserHash) Update(password string) error
- type UserList
- type UserListFull
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Argon2IDHasher ¶
type Argon2IDHasher struct {
Argon2IDParams
}
func NewArgon2IDHasher ¶
func NewArgon2IDHasher(params *Argon2IDParams) (*Argon2IDHasher, error)
func (*Argon2IDHasher) Check ¶
func (h *Argon2IDHasher) Check(password, hashStr string) (bool, error)
func (*Argon2IDHasher) Generate ¶
func (h *Argon2IDHasher) Generate(password string) (string, error)
func (*Argon2IDHasher) GetFormatID ¶
func (h *Argon2IDHasher) GetFormatID() string
type Argon2IDParams ¶
type Dir ¶
Dir represents a directory containing a whawty.auth password hash store. Use NewDir to create it.
func NewDirFromConfig ¶
func (*Dir) Authenticate ¶
func (d *Dir) Authenticate(user, password string) (isAuthenticated, isAdmin, upgradeable bool, lastchange time.Time, err error)
Authenticate checks if user and password are a valid combination. It also returns whether user is an admin, the password is upgradeable and when the password was last changed.
func (*Dir) ListFull ¶
func (d *Dir) ListFull() (UserListFull, error)
ListFull returns a list of all users in the store. This includes users with unsupported hash formats.
func (*Dir) RemoveUser ¶
RemoveUser removes user from the store.
func (*Dir) SetAdmin ¶
SetAdmin changes the admin status of user. It is an error if the user does not exist.
func (*Dir) UpdateUser ¶
UpdateUser changes the password of user. It is an error if the user does not exist.
type ScryptAuthHasher ¶
type ScryptAuthHasher struct {
// contains filtered or unexported fields
}
func NewScryptAuthHasher ¶
func NewScryptAuthHasher(params *ScryptAuthParams) (*ScryptAuthHasher, error)
func (*ScryptAuthHasher) Check ¶
func (h *ScryptAuthHasher) Check(password, hashStr string) (isAuthenticated bool, err error)
func (*ScryptAuthHasher) Generate ¶
func (h *ScryptAuthHasher) Generate(password string) (string, error)
func (*ScryptAuthHasher) GetFormatID ¶
func (h *ScryptAuthHasher) GetFormatID() string
type ScryptAuthParams ¶
type User ¶
User holds basic information about a specific user. This is used as the value type for UserList.
type UserFull ¶
type UserFull struct { IsAdmin bool `json:"admin"` LastChanged time.Time `json:"lastchanged"` IsValid bool `json:"valid"` IsSupported bool `json:"supported"` FormatID string `json:"formatid"` ParamID uint `json:"paramid"` }
UserFull holds additional information about a specific user. This is used as the value type for UserListFull.
type UserHash ¶
type UserHash struct {
// contains filtered or unexported fields
}
UserHash is the representation of a single user hash file inside the store. Use NewUserHash to create it.
func NewUserHash ¶
NewUserHash creates a new whawty.auth UserHash for user inside BaseDir.
func (*UserHash) Authenticate ¶
func (u *UserHash) Authenticate(password string) (isAuthenticated, isAdmin, upgradeable bool, lastchange time.Time, err error)
Authenticate checks the user password. It also returns whether user is an admin, the password is upgradable and when the password was last changed.
func (*UserHash) Exists ¶
Exists checks if user exists. It also returns whether user is an admin. This returns true even if the user's hash file format is not supported
type UserListFull ¶
UserListFull is the return value of ListFull(). The key of the map is the username.