users

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 5 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthError

type AuthError struct {
	Response []byte
	Code     int
	JSON     bool // default false
}

AuthError implements Error q: who should control the response? should it be json? html? what is the status code? should this be described in protobuf?

type AuthFunc

type AuthFunc func(req *http.Request) (bool, *http.Cookie, error)

AuthFunc is for users of this library to implement

type Authenticator

type Authenticator interface {
	// Authenticate returns true if the authenticator was used.
	// userToken is empty if not authenticated
	Authenticate(rw http.ResponseWriter, req *http.Request) (handled bool, userToken *string, err error)

	// Logout the given request
	Logout(rw http.ResponseWriter, req *http.Request)
}

type Module

type Module struct {
	Logger            *logger.Module
	BaseAuthenticator Authenticator // defaults to MultiAuthenticate
	Authenticators    []Authenticator
}

func (*Module) Authenticate

func (m *Module) Authenticate(rw http.ResponseWriter, req *http.Request) (handled bool, userToken *string, err error)

func (*Module) AuthenticateWithList

func (m *Module) AuthenticateWithList(authenticators []Authenticator, rw http.ResponseWriter, req *http.Request) (handled bool, userToken *string, err error)

func (*Module) Init

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

Init implements the Module interface method

func (*Module) Logout

func (m *Module) Logout(rw http.ResponseWriter, req *http.Request)

func (*Module) MustWithAuth

func (m *Module) MustWithAuth(next router.Handle) router.Handle

func (*Module) MustWithAuthList

func (m *Module) MustWithAuthList(authenticators []Authenticator, next router.Handle) router.Handle

func (*Module) RegisterAuthenticator

func (m *Module) RegisterAuthenticator(a Authenticator)

RegisterAuthenticator registers a new authenticator

func (*Module) WithAuth

func (m *Module) WithAuth(next router.Handle) router.Handle

func (*Module) WithAuthList

func (m *Module) WithAuthList(authenticators []Authenticator, next router.Handle) router.Handle

type UserTokenKey

type UserTokenKey struct{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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