user

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package user provides management of user accounts.

Index

Constants

View Source
const ManifestType = "user"

ManifestType is the type of the manifest used to represent user accounts.

View Source
const UsernameAtHostnameLabel = "username"

UsernameAtHostnameLabel is the manifest label identifying users by username@hostname.

Variables

View Source
var ErrUserNotFound = errors.New("user not found")

ErrUserNotFound is returned to indicate that a user was not found in the system.

Functions

func DeleteUserProfile

func DeleteUserProfile(ctx context.Context, w repo.RepositoryWriter, username string) error

DeleteUserProfile removes user profile with a given username.

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

func SetUserProfile(ctx context.Context, w repo.RepositoryWriter, p *Profile) error

SetUserProfile creates or updates user profile.

func ValidateUsername

func ValidateUsername(name string) error

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"` // indicates how password is hashed, deprecated in favor of KeyDerivationAlgorithm
	KeyDerivationAlgorithm string `json:"keyDerivationAlgorithm,omitempty"`
	PasswordHash           []byte `json:"passwordHash"`
}

Profile describes information about a single user.

func GetUserProfile

func GetUserProfile(ctx context.Context, r repo.Repository, username string) (*Profile, error)

GetUserProfile returns the user profile with a given username.

func ListUserProfiles

func ListUserProfiles(ctx context.Context, rep repo.Repository) ([]*Profile, error)

ListUserProfiles gets the list of all user profiles in the system.

func (*Profile) IsValidPassword

func (p *Profile) IsValidPassword(password string) bool

IsValidPassword determines whether the password is valid for a given user.

func (*Profile) SetPassword

func (p *Profile) SetPassword(password string) error

SetPassword changes the password for a user profile.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL