users

package
v1.0.3-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllowedPermissions = []string{"read", "write"}

Functions

func DerivePasswordKey added in v1.0.3

func DerivePasswordKey(password string, passwordSaltHex ...string) ([]byte, []byte, error)

DerivePasswordKey derives a password key by hashing the given password with a salt.

Types

type User added in v1.0.3

type User struct {
	Name         string
	PasswordHash []byte
	PasswordSalt []byte
	Permissions  map[string]struct{}
}

func NewUser added in v1.0.3

func NewUser(username, passwordHashHex, passwordSaltHex string, permissions map[string]struct{}) (*User, error)

func (*User) Clone added in v1.0.3

Clone returns a copy of a user.

func (*User) ID added in v1.0.3

func (u *User) ID() util.ComparableString

func (*User) PermissionsSlice added in v1.0.3

func (u *User) PermissionsSlice() []string

PermissionsSlice returns the permissions of the user as a slice.

type UserManager added in v1.0.3

type UserManager struct {
	// contains filtered or unexported fields
}

UserManager handles the list of users that are stored in the user config. It calls a function if the list changed.

func NewUserManager added in v1.0.3

func NewUserManager(storeCallback func([]*User) error) *UserManager

NewUserManager creates a new user manager.

func (*UserManager) AddUser added in v1.0.3

func (m *UserManager) AddUser(user *User) error

AddUser adds a user to the user manager.

func (*UserManager) ChangeUserPassword added in v1.0.3

func (m *UserManager) ChangeUserPassword(name string, passwordHash, passwordSalt []byte) error

ChangeUserPassword changes the password of a user.

func (*UserManager) ChangeUserPermissions added in v1.0.3

func (m *UserManager) ChangeUserPermissions(name string, permissions map[string]struct{}) error

ChangeUserPermissions changes the permissions of a user.

func (*UserManager) EnableStoreOnChange added in v1.0.3

func (m *UserManager) EnableStoreOnChange()

func (*UserManager) ModifyUser added in v1.0.3

func (m *UserManager) ModifyUser(user *User) error

ModifyUser modifies a user in the user manager.

func (*UserManager) RemoveUser added in v1.0.3

func (m *UserManager) RemoveUser(name string) error

RemoveUser removes a user from the user manager.

func (*UserManager) SanitizePermissions added in v1.0.3

func (m *UserManager) SanitizePermissions(permissions map[string]struct{}) map[string]struct{}

func (*UserManager) User added in v1.0.3

func (m *UserManager) User(name string) (*User, error)

User returns a copy of a user.

func (*UserManager) Users added in v1.0.3

func (m *UserManager) Users() map[string]*User

Users returns a copy of all known users.

Jump to

Keyboard shortcuts

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