user

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidCredentials = errors.New("invalid credentials")

Functions

func NewBasicAuth

func NewBasicAuth(userDatabase UsersDatabase) *basicAuthContext

func NewSimpleAuth

func NewSimpleAuth(userDatabase UsersDatabase) *simpleAuthContext

func RequireAuthentication

func RequireAuthentication(next http.Handler) http.Handler

Types

type User

type User struct {
	Username string `json:"username" yaml:"-"`
	Email    string `json:"email" yaml:"email"`
	Name     string `json:"name" yaml:"name"`
	Password string `json:"-" yaml:"password"`
}

func CreateUser

func CreateUser(path string, user User, hashPassword bool) (User, error)

func UserFromContext

func UserFromContext(ctx context.Context) *User

type UsersDatabase

type UsersDatabase struct {
	Users    map[string]*User `yaml:"users"`
	LastRead time.Time        `yaml:"-"`
	LastSave time.Time        `yaml:"-"`
	Path     string           `yaml:"-"`
}

func ReadUsersFromFile

func ReadUsersFromFile(path string) (UsersDatabase, error)

func (*UsersDatabase) Find

func (u *UsersDatabase) Find(username string) *User

func (*UsersDatabase) FindByPassword

func (u *UsersDatabase) FindByPassword(username, password string) *User

Jump to

Keyboard shortcuts

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