store

package
v0.0.0-...-16263d8 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PwDB

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

PwDB implements the Store interface to load and store data in an SQL database. Data is stored in a table called "user" with three string columns, id, cryptword, and permissions, where the permissions value is a comma-separated list of permission names.

func NewPwDB

func NewPwDB(db *sql.DB) *PwDB

func (*PwDB) CreatePasswordTable

func (pdb *PwDB) CreatePasswordTable() error

func (*PwDB) Load

func (pdb *PwDB) Load() (*users.Users, error)

Load does nothing when we are using a database.

func (*PwDB) Save

func (pdb *PwDB) Save(_ *users.Users) error

Save does nothing when we are using a database.

func (*PwDB) SetSaltword

func (pdb *PwDB) SetSaltword(username, cryptword string)

func (*PwDB) User

func (pdb *PwDB) User(username string) *users.User

func (*PwDB) UserCount

func (pdb *PwDB) UserCount() int

type PwFile

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

PwFile implements the Store interface to load and store data in a file similar to a Unix /etc/passwd file. Each line has data for one user in colon-separated fields with the format

username:password:permissions

where the permissions field is a comma-separated list of permission names.

func NewPwFile

func NewPwFile(filename string) *PwFile

func (*PwFile) CreatePasswordFile

func (pf *PwFile) CreatePasswordFile() error

func (*PwFile) Load

func (pf *PwFile) Load() error

func (*PwFile) Save

func (pf *PwFile) Save() error

func (*PwFile) SetSaltword

func (pf *PwFile) SetSaltword(username, saltword string)

func (*PwFile) User

func (pf *PwFile) User(username string) *users.User

func (*PwFile) UserCount

func (pf *PwFile) UserCount() int

type Store

type Store interface {
	Load() error                           // Load our data before other operations
	Save() error                           // Save our data after other operations
	User(username string) *users.User      // Retrieve a user record by id
	SetSaltword(username, saltword string) // Set the saltword for a user
	UserCount() int                        // Get the number of users in our records
}

The Store interface is used by our classes that need to load and save the user/password/premissions data.

Jump to

Keyboard shortcuts

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