Documentation ¶
Overview ¶
Package user provides management of user accounts.
Index ¶
- Constants
- Variables
- func DeleteUserProfile(ctx context.Context, w repo.RepositoryWriter, username string) error
- func HashPassword(password string) (string, error)
- func LoadProfileMap(ctx context.Context, rep repo.Repository, old map[string]*Profile) (map[string]*Profile, error)
- func SetUserProfile(ctx context.Context, w repo.RepositoryWriter, p *Profile) error
- func ValidateUsername(name string) error
- type Profile
Constants ¶
const ( // ScryptHashVersion is the version representation of the scrypt algorithm. ScryptHashVersion = 1 // Pbkdf2HashVersion is the version representation of the pbkdf2 algorithm. Pbkdf2HashVersion = 2 )
const ManifestType = "user"
ManifestType is the type of the manifest used to represent user accounts.
const UsernameAtHostnameLabel = "username"
UsernameAtHostnameLabel is the manifest label identifying users by username@hostname.
Variables ¶
var ErrUserAlreadyExists = errors.New("user already exists")
ErrUserAlreadyExists indicates that a user already exist in the system when attempting to create a new one.
var ErrUserNotFound = errors.New("user not found")
ErrUserNotFound is returned to indicate that a user was not found in the system.
Functions ¶
func DeleteUserProfile ¶
DeleteUserProfile removes user profile with a given username.
func HashPassword ¶ added in v0.18.0
HashPassword computes the hash for the given password and an encoded hash that can be passed to Profile.SetPasswordHash().
func LoadProfileMap ¶
func LoadProfileMap(ctx context.Context, rep repo.Repository, old map[string]*Profile) (map[string]*Profile, error)
LoadProfileMap returns the map of all users profiles in the repository by username, using old map as a cache.
func SetUserProfile ¶
SetUserProfile creates or updates user profile.
func ValidateUsername ¶
ValidateUsername returns an error if the given username is invalid.
Types ¶
type Profile ¶
type Profile struct { ManifestID manifest.ID `json:"-"` Username string `json:"username"` PasswordHashVersion int `json:"passwordHashVersion,omitempty"` PasswordHash []byte `json:"passwordHash"` }
Profile describes information about a single user.
func GetNewProfile ¶ added in v0.18.0
GetNewProfile returns a profile for a new user with the given username. Returns ErrUserAlreadyExists when the user already exists.
func GetUserProfile ¶
GetUserProfile returns the user profile with a given username. Returns ErrUserNotFound when the user does not exist.
func ListUserProfiles ¶
ListUserProfiles gets the list of all user profiles in the system.
func (*Profile) IsValidPassword ¶
IsValidPassword determines whether the password is valid for a given user.
func (*Profile) SetPassword ¶
SetPassword changes the password for a user profile.
func (*Profile) SetPasswordHash ¶ added in v0.18.0
SetPasswordHash decodes and validates encodedhash, if it is a valid hash then it sets it as the password hash for the user profile.