users

package
v1.0.1-rc.7 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

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