Documentation ¶
Index ¶
- Constants
- func Base6424(src string) string
- func GenString(size int) string
- func GenerateDovecotPassword(password, salt string, rounds int) string
- type Alias
- type Aliases
- type DBM
- func (db *DBM) AddSite(name string) (int64, error)
- func (db *DBM) AddUser(username, password, email, first, last, data, tokens string, cost int) (*User, error)
- func (db *DBM) ClearFlag(key string) error
- func (db *DBM) Connect(name string) error
- func (db *DBM) ConnectionString() string
- func (db *DBM) Create(name string) error
- func (db *DBM) DatabaseExists(name string) bool
- func (db *DBM) Drop(name string) error
- func (db *DBM) GetAlias(alias string) (string, error)
- func (db *DBM) GetFlag(key string) bool
- func (db *DBM) GetSitesForUser(u *User) error
- func (db *DBM) GetUser(id int64) (*User, error)
- func (db *DBM) GetUserByName(name string) (*User, error)
- func (db *DBM) GetUsers(limit int64) ([]*User, error)
- func (db *DBM) GetVar(key string) string
- func (db *DBM) InitDatabase() error
- func (db *DBM) InitMailTables() error
- func (db *DBM) RemoveAlias(alias string) error
- func (db *DBM) RemoveAliases(target string) error
- func (db *DBM) RemoveSite(id int64) error
- func (db *DBM) RemoveSiteByName(name string) error
- func (db *DBM) RemoveUser(id int64) error
- func (db *DBM) RemoveUserByName(name string) error
- func (db *DBM) RemoveVar(key string) error
- func (db *DBM) SaveUser(u *User) error
- func (db *DBM) SearchAliases(match string) (*Aliases, error)
- func (db *DBM) SearchSites(match string) (*Sites, error)
- func (db *DBM) SetAlias(alias, target string) error
- func (db *DBM) SetFlag(key string, flag bool) error
- func (db *DBM) SetVar(key, value string) error
- type Group
- type Site
- type Sites
- type User
Constants ¶
const DefaultName = "accounts"
Variables ¶
This section is empty.
Functions ¶
func GenerateDovecotPassword ¶ added in v0.4.0
GenerateDovecotPassword creates a Dovecot-compatible password with the SHA512-CRYPT algorithm prefix.
Types ¶
type Aliases ¶ added in v0.6.0
type Aliases struct {
List []Alias `json:"aliases"`
}
Aliases container.
type DBM ¶
DBM is a DB manager for user accounts and groups.
func (*DBM) AddUser ¶
func (db *DBM) AddUser(username, password, email, first, last, data, tokens string, cost int) (*User, error)
AddUser creates a new User. This may fail.
func (*DBM) ConnectionString ¶
func (*DBM) DatabaseExists ¶
DatabaseExists checks for the existence of the actual database.
func (*DBM) GetSitesForUser ¶ added in v0.4.0
GetSitesForUser fills the Sites field in the User struct.
func (*DBM) GetUserByName ¶
GetUserByName for when you don't have an ID.
func (*DBM) InitDatabase ¶
InitDatabase creates the tables, functions and triggers required for the full account system.
func (*DBM) InitMailTables ¶ added in v0.6.0
InitMailTables for mail mode.
func (*DBM) RemoveAlias ¶ added in v0.6.0
RemoveAlias deletes an alias.
func (*DBM) RemoveAliases ¶ added in v0.6.0
RemoveAliases deletes all aliases with the same target.
func (*DBM) RemoveSite ¶ added in v0.8.0
RemoveSite by ID.
func (*DBM) RemoveSiteByName ¶ added in v0.8.0
RemoveSiteByName for when that's more convenient.
func (*DBM) RemoveUser ¶ added in v0.8.0
RemoveUser by ID.
func (*DBM) RemoveUserByName ¶ added in v0.8.0
RemoveUserByName for when that's needed.
func (*DBM) SearchAliases ¶ added in v0.6.0
SearchAliases finds aliases or targets containing the match string. Leave blank to list everything.
func (*DBM) SearchSites ¶ added in v0.8.0
SearchSites finds sites containing the match string. Leave blank to list everything.
func (*DBM) SetAlias ¶ added in v0.6.0
SetAlias creates or updates a new alias pointing to an existing target address (which may itself be an alias).
type Site ¶ added in v0.4.0
type Site struct { ID int64 `json:"id"` Name string `json:"name"` Created time.Time `json:"created"` Groups map[string]Group `json:"groups"` }
Site or domain.
type User ¶
type User struct { // ID of user in the database. ID int64 // Username to log in with. Usermame string // Password for user account. Password string // Salt for the password. Salt string // Email to verify account or reset password. Email string // Created timestamp. Created time.Time // Locked accounts can't log in. Locked bool // Sites the user is a member of. Sites []string // First name of user (optional). First string // Last name of user (optional). Last string // Data for the account. JSON field for all the customising you need. Data string // Tokens is meant to store any authentication tokens required for external sites. Tokens string }
User account structure holds basic login and personal information.
func (*User) CheckPassword ¶
CheckPassword against the account's hash.
func (*User) CompareDovecotHashAndPassword ¶ added in v0.4.0
func (*User) SetDovecotPassword ¶ added in v0.4.0
SetDovecotPassword sets a Dovecot-compatible password for the user.