Versions in this module Expand all Collapse all v1 v1.0.0 Jul 3, 2026 Changes in this version + var ErrInvalidCredentials = errors.New("auth: invalid email or password") + var ErrInvalidToken = errors.New("auth: invalid or expired token") + var ErrJWTNotConfigured = errors.New("auth: JWT secret not configured (must be at least 32 bytes)") + var ErrUnauthenticated = errors.New("auth: unauthenticated") + func CheckPassword(hash, password string) bool + func HashPassword(password string, cost ...int) (string, error) + type Claims struct + Email string + UserID int64 + type Guard struct + func NewGuard(provider UserProvider, sessions *session.Manager, jwtSecret string) *Guard + func (g *Guard) Attempt(ctx context.Context, email, password string, sess *session.Session) (User, error) + func (g *Guard) Check(ctx context.Context, sess *session.Session) bool + func (g *Guard) IssueToken(user User, ttl time.Duration) (string, error) + func (g *Guard) Logout(ctx context.Context, sess *session.Session) error + func (g *Guard) ParseToken(tokenStr string) (*Claims, error) + func (g *Guard) UserFromSession(ctx context.Context, sess *session.Session) (User, error) + func (g *Guard) UserFromToken(ctx context.Context, tokenStr string) (User, error) + type User interface + GetEmail func() string + GetID func() int64 + GetPassword func() string + type UserProvider interface + FindByEmail func(ctx context.Context, email string) (User, error) + FindByID func(ctx context.Context, id int64) (User, error)