user

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Store is the userstore client
	Store = createClient()
)

Functions

func EncryptedReader

func EncryptedReader(key string, r io.Reader) (*cipher.StreamReader, error)

EncryptedReader wraps r with an OFB cipher stream.

func EncryptedWriter

func EncryptedWriter(key string, w io.Writer) (*cipher.StreamWriter, error)

EncryptedWriter wraps w with an OFB cipher stream.

func IntialiseStore

func IntialiseStore()

IntialiseStore does the setup for the user store starts a goroutine and handles user request in the background

Types

type Access

type Access interface {
	Get(name string) *User
}

Access to the user store

type PwEntry added in v0.10.11

type PwEntry struct {
	Passwd  []byte    `json:"payload"`
	Created time.Time `json:"created"`
	LastUse time.Time `json:"last_use"`
}

PwEntry stores pw history

type User

type User struct {
	Username         string     `json:"name"`
	Mail             string     `json:"email"`
	Longname         string     `json:"displayname"`
	DeprecatedPasswd []byte     `json:"payload"` // Deprecated: use History instead. (since v0.11.0)
	History          []*PwEntry `json:"history"`
	UserType         string     `json:"type"`
	// contains filtered or unexported fields
}

User stores a user and its encrypted password

func (*User) DisplayName

func (u *User) DisplayName() string

DisplayName returns the display name

func (*User) Email

func (u *User) Email() string

Email returns the email address

func (User) FailedLogins added in v0.12.0

func (u User) FailedLogins() int

FailedLogins the number of failed logins

func (User) IsValid

func (u User) IsValid() error

IsValid checks if all needed fields are set

func (*User) LoginSuccessfull added in v0.12.0

func (u *User) LoginSuccessfull()

LoginSuccessfull sets the last use of the password

func (*User) Name

func (u *User) Name() string

Name returns the name

func (*User) NewPassword added in v0.12.0

func (u *User) NewPassword() (string, error)

NewPassword generates a new password it does not store the password

func (*User) NextPassword added in v0.10.11

func (u *User) NextPassword() string

NextPassword increases the password index and returns the decrypted PW retruns empty string "" if no more passwords are present

func (*User) NumPasswdChg added in v0.12.2

func (u *User) NumPasswdChg(d time.Duration) int

NumPasswdChg number of times the password was changed

func (*User) Password

func (u *User) Password() string

Password decrypts the password

func (*User) PasswordCreated added in v0.10.11

func (u *User) PasswordCreated() time.Time

PasswordCreated returns the time when the password was created

func (User) PasswordHistoryCount added in v0.11.0

func (u User) PasswordHistoryCount() int

PasswordHistoryCount returns the number of PW in the history

func (*User) PasswordLastUse added in v0.10.11

func (u *User) PasswordLastUse() time.Time

PasswordLastUse returns the time when the password was last accessed

func (*User) ResetPasswordIndex added in v0.12.0

func (u *User) ResetPasswordIndex()

ResetPasswordIndex start with the first password and reset the number of failed logins to 0

func (*User) Save added in v0.12.0

func (u *User) Save() error

Save the user to the store

func (*User) SetPassword

func (u *User) SetPassword(pw string)

SetPassword encrypts the password

func (User) String

func (u User) String() string

String implements stringer

func (*User) Type

func (u *User) Type() string

Type returns what kind of user it is

Jump to

Keyboard shortcuts

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