Versions in this module Expand all Collapse all v1 v1.0.39 Oct 28, 2026 Changes in this version + const SessionCookie + func GenerateRecoveryCodes(n int) ([]string, error) + func GenerateTOTPSecret() (string, error) + func SessionTokenFromRequest(r *http.Request) string + func TOTPCode(secret string, t time.Time) (string, error) + func ValidateTOTP(secret, code string, t time.Time, window int) bool + func VerifyCaptcha(token, provider string) error + type WebAuthnChallenge struct + Challenge string + RPID string + func BeginPasskeyRegistration(userID string) (WebAuthnChallenge, error) v1.0.38 Oct 20, 2026 Changes in this version + const MaxPasswordLength + const MinPasswordLength + const UserContextKey + var ErrAPITokenExpired = errors.New("api token has expired") + var ErrAPITokenNotFound = errors.New("api token not found") + var ErrInvalidCredentials = errors.New("invalid credentials") + var ErrInvalidRecoveryKey = errors.New("invalid recovery key") + var ErrInvalidToken = errors.New("invalid token") + var ErrLocalAuthDisabled = errors.New("local authentication is disabled") + var ErrNoAuthProvider = errors.New("no authentication provider is enabled") + var ErrPasswordTooWeak = errors.New("password does not meet the minimum requirements") + var ErrRegistrationDisabled = errors.New("registration is disabled") + var ErrSessionExpired = errors.New("session expired") + var ErrSessionTimeoutMin = errors.New("session timeout must be at least 300 seconds (5 minutes)") + var ErrUserNotActive = errors.New("user is not active") + func ValidatePassword(password string) error + func WithUser(ctx context.Context, user *AuthenticatedUser) context.Context + type AuthenticatedUser struct + Email string + ID string + Provider string + Roles []string + Username string + func GetUserFromContext(ctx context.Context) *AuthenticatedUser + type LoginThrottle struct + func NewLoginThrottle() *LoginThrottle + func NewLoginThrottleWithLimits(max int, window, lockout time.Duration) *LoginThrottle + func (t *LoginThrottle) Allow(key string) (bool, time.Duration) + func (t *LoginThrottle) Count() int + func (t *LoginThrottle) Failure(key string) time.Duration + func (t *LoginThrottle) Prune() int + func (t *LoginThrottle) Reset(key string) + type Manager struct + func NewManager(store *db.Store, enforcer *rbac.Enforcer, cfg *config.AuthConfig) (*Manager, error) + func (m *Manager) AnonymousUser() *AuthenticatedUser + func (m *Manager) AuthenticateFromHeader(ctx context.Context, authHeader string) (*AuthenticatedUser, error) + func (m *Manager) ChangePassword(ctx context.Context, userID, oldPassword, newPassword string) error + func (m *Manager) CreateLocalUser(ctx context.Context, username, email, password string) (*db.User, error) + func (m *Manager) GenerateAPIToken(ctx context.Context, userID, name string, expiresInDays *int32) (string, *db.APIToken, error) + func (m *Manager) GenerateModuleToken(ctx context.Context, userID, moduleName, moduleID string) (string, *db.APIToken, error) + func (m *Manager) GetConfig() *config.AuthConfig + func (m *Manager) GetRecoveryKey() string + func (m *Manager) InvalidateUserSessions(ctx context.Context, userID, exceptToken string) error + func (m *Manager) IsAnonymousAccessEnabled() bool + func (m *Manager) IsAnyAuthEnabled() bool + func (m *Manager) IsLocalAuthEnabled() bool + func (m *Manager) IsRegistrationAllowed() bool + func (m *Manager) Login(ctx context.Context, username, password string) (*db.User, []string, string, time.Time, error) + func (m *Manager) Logout(ctx context.Context, token string) error + func (m *Manager) NoAuthAllowed() bool + func (m *Manager) RecoveryKeyCreated() bool + func (m *Manager) RotateRecoveryKey(ctx context.Context) (string, error) + func (m *Manager) UpdateSettings(ctx context.Context, localEnabled, allowReg, anonAccess *bool, ...) error + func (m *Manager) UseRecoveryKey(ctx context.Context, key string) error + func (m *Manager) ValidateAPIToken(ctx context.Context, rawToken string) (*AuthenticatedUser, error) + func (m *Manager) ValidateSession(ctx context.Context, token string) (*AuthenticatedUser, error) + type OIDCHandler struct + func NewOIDCHandler(manager *Manager, store *db.Store, cfg *config.OIDCConfig, log *logger.Logger) (*OIDCHandler, error) + func (h *OIDCHandler) HandleCallback(w http.ResponseWriter, r *http.Request) + func (h *OIDCHandler) HandleLogin(w http.ResponseWriter, r *http.Request) + func (h *OIDCHandler) IsEnabled() bool