unpwstore

package
v0.0.0-...-7bb3757 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPasswordFile = "hub.passwd"

DefaultPasswordFile is the recommended password filename for Hub authentication

Variables

This section is empty.

Functions

func WritePasswordsToTempFile

func WritePasswordsToTempFile(
	folder string, passwords map[string]string) (tempFileName string, err error)

WritePasswordsToTempFile write the given passwords to temp file in the given folder This returns the name of the new temp file.

Types

type PasswordFileStore

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

PasswordFileStore stores a list of user login names and their password info It includes a file watcher to automatically reload on update.

func NewPasswordFileStore

func NewPasswordFileStore(filepath string, clientID string) *PasswordFileStore

NewPasswordFileStore creates a new instance of a file based username/password store Note: this store is intended for one writer and many readers. Multiple concurrent writes are not supported and might lead to one write being ignored.

filepath location of the file store. See also DefaultPasswordFile for the recommended name
clientID is authservice ID to include in logging

func (*PasswordFileStore) Close

func (pwStore *PasswordFileStore) Close()

Close the store

func (*PasswordFileStore) Count

func (pwStore *PasswordFileStore) Count() int

Count nr of entries in the store

func (*PasswordFileStore) GetPasswordHash

func (pwStore *PasswordFileStore) GetPasswordHash(username string) string

GetPasswordHash returns the stored encoded password hash for the given user returns hash or "" if user not found

func (*PasswordFileStore) Open

func (pwStore *PasswordFileStore) Open() error

Open the store This reads the password file and subscribes to file changes

func (*PasswordFileStore) Reload

func (pwStore *PasswordFileStore) Reload() error

Reload the password store from file and subscribe to file changes If subscription already exists it is removed and renewed.

File format:  <loginname>:bcrypt(passwd)

Returns error if the file could not be opened

func (*PasswordFileStore) SetPasswordHash

func (pwStore *PasswordFileStore) SetPasswordHash(loginID string, hash string) error

SetPasswordHash adds/updates the password hash for the given login ID Intended for use by administrators to add a new user or clients to update their password

Jump to

Keyboard shortcuts

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