auth

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadLogin      = errors.New("Bad Login")
	ErrNotAuthorized = errors.New("Not Authorized")
)

errors to be checked against returned

Functions

This section is empty.

Types

type Auther

type Auther interface {
	// Check should return a non-nil error for failed requests (like ErrBadLogin)
	// and it can pass custom data that is saved in the cookie through the first return argument
	Check(user, pass string) (interface{}, error)
}

Auther allows for custom authentication backends

type Handler

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

func NewHandler

func NewHandler(a Auther, options ...Option) (*Handler, error)

func (Handler) Authenticate

func (ah Handler) Authenticate(h http.Handler) http.Handler

func (Handler) AuthenticateRequest

func (ah Handler) AuthenticateRequest(r *http.Request) (interface{}, error)

func (Handler) Authorize

func (ah Handler) Authorize(w http.ResponseWriter, r *http.Request)

func (Handler) Logout

func (ah Handler) Logout(w http.ResponseWriter, r *http.Request)

type Option

type Option func(h *Handler) error

Option is a function that changes a handler in a certain way during initialization

func SetLanding

func SetLanding(l string) Option

SetLanding sets the url to where a client is redirect to after login

func SetLifetime

func SetLifetime(d time.Duration) Option

SetLifetime sets the duration of when a session expires after it is created

func SetLogout

func SetLogout(l string) Option

SetLogout sets the url to where a client is redirect to after logout uses Landing location by default

func SetSessionName

func SetSessionName(name string) Option

SetSessionName sets the name to use for sessions (ie. cookie name)

func SetStore

func SetStore(s sessions.Store) Option

SetStore sets the gorilla session.Store impl that should be used

Jump to

Keyboard shortcuts

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