Versions in this module Expand all Collapse all v0 v0.24.0 Jun 24, 2026 Changes in this version + var ErrInvalidCredentials = errors.New("guard: invalid credentials") + var ErrNoSession = errors.New("guard: no session on request") + var ErrUnauthenticated = errors.New("guard: unauthenticated") + type BcryptHasher struct + func (BcryptHasher) Verify(hash, plain string) bool + type Guard struct + func New(mgr *session.Manager, provider UserProvider, opts Options) *Guard + func (g *Guard) Attempt(ctx context.Context, w http.ResponseWriter, r *http.Request, ...) (User, error) + func (g *Guard) Check(r *http.Request) bool + func (g *Guard) Guest() func(http.Handler) http.Handler + func (g *Guard) ID(r *http.Request) string + func (g *Guard) Login(ctx context.Context, w http.ResponseWriter, r *http.Request, user User) error + func (g *Guard) Logout(ctx context.Context, w http.ResponseWriter, r *http.Request) error + func (g *Guard) Middleware() func(http.Handler) http.Handler + func (g *Guard) Remember() RememberStore + func (g *Guard) User(ctx context.Context, r *http.Request) (User, error) + type Hasher interface + Verify func(hash, plain string) bool + type Options struct + Hasher Hasher + HomePath string + LoginPath string + Remember RememberStore + type RememberStore interface + Forget func(ctx context.Context, token string) error + Issue func(ctx context.Context, userID string) (token string, err error) + Lookup func(ctx context.Context, token string) (userID string, ok bool, err error) + type User interface + AuthID func() string + AuthPasswordHash func() string + type UserProvider interface + FindByCredentials func(ctx context.Context, identifier string) (User, bool, error) + FindByID func(ctx context.Context, id string) (User, bool, error)