databaseauth

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthenticatePassword

func AuthenticatePassword(given, hashedActual string) bool

func HashPassword

func HashPassword(password, salt string) string

func WithLoginPath

func WithLoginPath(path string) option

WithLoginPath sets the path to listen for login requests. Optional.

func WithRedirectPath

func WithRedirectPath(path string) option

WithRedirectPath sets the path to redirect to after login. If set to blank, successful logins will not result in a redirect.

func WithUserStore

func WithUserStore(u UserStore) option

WithUserStore sets the backing user store. Required.

func WithoutLoginPath

func WithoutLoginPath() option

WithoutLoginPath disables the login handler

Types

type Module

type Module struct {
	Router   *router.Module
	Sessions *session.Module
	Logger   *logger.Module
	// contains filtered or unexported fields
}

Module databaseauth provides login via a database or database-like backend. It uses the session module. user authenticates via this module, then is a given a cookie which authenticates future requests. It registers m.loginPath for handling the login POST request.

func (*Module) Configure

func (m *Module) Configure(opts ...option)

func (*Module) Create

func (m *Module) Create(email, password string) (string, error)

Create a new user

func (*Module) Init

func (m *Module) Init(c *service.Config)

func (*Module) Login

func (m *Module) Login(email, password string) (string, bool, error)

Login with email and password, returns user id if valid

type UserStore

type UserStore interface {
	Create(email, password string) (id string, err error)
	Get(email string) (id, hashedPassword string, err error)
}

Jump to

Keyboard shortcuts

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