Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("no such user") // ErrNotFound is returned when trying to do something with uknown username ErrValidateUser = errors.New("missing username or secret field for user") // ErrValidateUser is returned when User struct is missing Username or Secret fields ErrIncorrectPassword = errors.New("incorrect password") // ErrIncorrectPassword is returned when user password does not check out ErrUnknownStorageType = errors.New("unknown storage type, use 'postgres' or 'sqlite'") // ErrUnknownStorageType is returned when unknown value is passed as storage type in RepoConfig )
Functions ¶
func BcryptHash ¶
BcryptHash return bcrypt hash of provided password.
func NewWithPG ¶ added in v1.1.0
func NewWithPG(dsn string) (Repository, Authenticator, error)
NewNewWithPG return Repository and Authenticator using connection to Postgres DB via specified DSN under the hood.
func NewWithSQLite ¶ added in v1.1.0
func NewWithSQLite(path string) (Repository, Authenticator, error)
NewWithSQLite return Repository and Authenticator using SQLite DB with specified path under the hood.
Types ¶
type Authenticator ¶
type Repository ¶
type Repository interface {
Get(username string) (User, error) // Get returns user with username
Put(user User) error // Put saves User struct
Upd(user User) error // Update updates User
Del(username string) error // Del deletes user with username
Rename(oldname string, newname string) error // Rename renames user with oldname setting username to newname
Close() error // Closes safely closes the repository
}
Repository is a basic CRUD interface to store User structs.
type User ¶
type User struct {
Username string // username
Secret string // secret (e.g. password hash)
Enabled bool // is user active
Attrs map[string]string // various stuff you might put here
Created time.Time // create time
Updated time.Time // last update time
}
User is a very basic struct representing user
Source Files
¶
Click to show internal directories.
Click to hide internal directories.