types

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PathApiLogin              string = "api/login"
	PathApiLoginCodeVerify    string = "api/login-code-verify"
	PathApiLogout             string = "api/logout"
	PathApiRegister           string = "api/register"
	PathApiRegisterCodeVerify string = "api/register-code-verify"
	PathApiRestorePassword    string = "api/restore-password"
	PathApiResetPassword      string = "api/reset-password"
	PathApiImpersonateStart   string = "api/impersonate/start"
	PathApiImpersonateStop    string = "api/impersonate/stop"
	PathApiAuthKnightCallback string = "api/authknight/callback"
)

Path constants for API endpoints

View Source
const (
	PathLogin              string = "login"
	PathLoginCodeVerify    string = "login-code-verify"
	PathLogout             string = "logout"
	PathRegister           string = "register"
	PathRegisterCodeVerify string = "register-code-verify"
	PathPasswordRestore    string = "password-restore"
	PathPasswordReset      string = "password-reset"
)

Path constants for UI pages

View Source
const (
	EndpointLogin              string = "login"
	EndpointLoginCodeVerify    string = "login_code_verify"
	EndpointRegister           string = "register"
	EndpointRegisterCodeVerify string = "register_code_verify"
	EndpointPasswordReset      string = "password_reset"
	EndpointPasswordRestore    string = "password_restore"
	EndpointImpersonateStart   string = "impersonate_start"
	EndpointImpersonateStop    string = "impersonate_stop"
	EndpointAuthKnightCallback string = "authknight_callback"
)

Endpoint constants for rate limiting

View Source
const (
	CookieUnset        = ""
	CookieSecure       = "secure"
	CookieInsecure     = "insecure"
	CookieHttpOnly     = "httponly"
	CookieHttpWritable = "httpwritable"
)
View Source
const (
	// Validation errors
	MsgEmailRequired                     = "Email is required field"
	MsgPasswordRequired                  = "Password is required field"
	MsgFirstNameRequired                 = "First name is required field"
	MsgLastNameRequired                  = "Last name is required field"
	MsgTokenRequired                     = "Token is required field"
	MsgUserIDRequired                    = "user_id is required field"
	MsgVerificationCodeRequired          = "Verification code is required field"
	MsgPasswordsDoNotMatch               = "Passwords do not match"
	MsgEmailInvalid                      = "Email is invalid"
	MsgVerificationCodeInvalidLength     = "Verification code is invalid length"
	MsgVerificationCodeInvalidCharacters = "Verification code contains invalid characters"
	MsgVerificationCodeExpired           = "Verification code has expired"
	MsgSerializedFormatMalformed         = "Serialized format is malformed"

	// Auth errors
	MsgInvalidCredentials = "Invalid credentials"
	MsgUserNotFound       = "User not found"

	// Operation errors
	MsgRegistrationFailed          = "registration failed."
	MsgRegistrationFailedFn        = "registration failed. FuncUserRegister function not defined"
	MsgRegistrationFailedEmailTpl  = "registration failed. FuncEmailTemplateRegisterCode function not defined"
	MsgRegistrationFailedEmailSend = "registration failed. FuncEmailSend function not defined"
	MsgRegistrationFailedGeneric   = "Registration failed. Please try again later"
	MsgPasswordResetFailed         = "Password reset failed. Please try again later"
	MsgLogoutFailed                = "Logout failed. Please try again later"
	MsgPasswordValidationFailed    = "Password validation failed"

	// Generic internal errors
	MsgInternalServer        = "Internal server error. Please try again later"
	MsgFailedToProcess       = "Failed to process request. Please try again later"
	MsgFailedToGenerateCode  = "Failed to generate verification code. Please try again later"
	MsgFailedToSendEmail     = "Failed to send email. Please try again later"
	MsgLinkNotValidOrExpired = "Link not valid or expired"
	MsgTooManyRequests       = "Too many requests. Please try again later."

	// Email subjects
	EmailSubjectRegistrationCode = "Registration Code"

	// Success messages
	MsgLoginSuccess          = "login success"
	MsgRegistrationSuccess   = "registration success"
	MsgRegistrationCodeSent  = "Registration code was sent successfully"
	MsgLoginCodeSent         = "Login code was sent successfully"
	MsgPasswordResetLinkSent = "Password reset link was sent to your e-mail"
	MsgPasswordResetSuccess  = "Password has been reset successfully"

	// Impersonation messages
	MsgImpersonationStarted    = "impersonation started"
	MsgImpersonationStopped    = "impersonation stopped"
	MsgNotImpersonating        = "not currently impersonating"
	MsgAlreadyImpersonating    = "already impersonating — stop first"
	MsgImpersonationNotEnabled = "impersonation is not enabled"
	MsgImpersonationForbidden  = "impersonation is not allowed"
	MsgImpersonationFailed     = "impersonation failed. Please try again later"

	// AuthKnight messages
	MsgAuthKnightOnceRequired       = "Once token is required"
	MsgAuthKnightVerificationFailed = "AuthKnight verification failed"
	MsgAuthKnightAPIError           = "AuthKnight API error. Please try again later"
	MsgAuthKnightTempKeyStoreFailed = "Failed to store verification data. Please try again later"
	MsgAuthKnightRegistrationFailed = "Registration failed. Please try again later"
)

Error messages for validation and internal failures. These constants centralize all user-facing strings so applications can override or localize them without modifying core business logic.

View Source
const (
	LoginMethodPassword     = "password"
	LoginMethodPasswordless = "passwordless"
)

Login method identifiers used by RecordLoginAttempt.

View Source
const AuthKnightBaseURL string = "https://authknight.com"

AuthKnightBaseURL is the base URL of the AuthKnight service.

View Source
const ImpersonationKeyPrefix = "imp:"

ImpersonationKeyPrefix is the prefix used for temporary keys that store the original admin auth token during an impersonation session.

Variables

View Source
var CookieName = "authtoken"

CookieName is the default cookie name used by auth token helpers. It is a variable for backward compatibility and global override scenarios, but it should be set at init-time before any auth instances are used. For per-instance customization, use CookieConfig.Name or SetCookieName.

Functions

func ResolveHttpOnly added in v0.34.0

func ResolveHttpOnly(s string) bool

func ResolveSecure added in v0.34.0

func ResolveSecure(s string) bool

Types

type AuthAuthKnightInterface added in v0.35.0

type AuthAuthKnightInterface interface {
	AuthSharedInterface

	// LinkAuthKnightLogin returns the AuthKnight-hosted login URL
	// with back_url and next_url parameters set.
	LinkAuthKnightLogin(backURL, nextURL string) string

	// LinkAuthKnightRedirect builds the full AuthKnight login URL from the request,
	// deriving back_url (cancel) and next_url (callback) from the request scheme+host.
	LinkAuthKnightRedirect(r *http.Request) string

	// LinkAuthKnightCallback returns the callback URL on this server
	// that AuthKnight will redirect to after successful authentication.
	LinkAuthKnightCallback() string

	// IsAuthKnight returns true when the instance is configured for AuthKnight mode.
	IsAuthKnight() bool

	// AuthKnight-specific accessors
	GetAuthKnightUserFindByEmail() func(ctx context.Context, email string, options UserAuthOptions) (string, error)
	GetAuthKnightUserRegister() func(ctx context.Context, email, firstName, lastName string, options UserAuthOptions) (string, error)
	GetAuthKnightRedirectURL() func(ctx context.Context, userID string) string
	GetAuthKnightHTTPTimeout() time.Duration
}

AuthAuthKnightInterface represents AuthKnight-based authentication. It extends the shared interface with AuthKnight-specific helpers.

type AuthPasswordInterface added in v0.30.0

type AuthPasswordInterface interface {
	AuthSharedInterface

	// Password reset URLs (web and API).
	LinkPasswordRestore() string
	LinkPasswordReset(token string) string
	LinkApiPasswordRestore() string
	LinkApiPasswordReset() string
}

AuthPasswordInterface represents username/password based authentication. It extends the shared interface with password-reset specific helpers.

type AuthPasswordlessInterface added in v0.30.0

type AuthPasswordlessInterface interface {
	AuthSharedInterface

	// Passwordless-only URL helpers.
	LinkLoginCodeVerify() string
	LinkApiLoginCodeVerify() string
}

AuthPasswordlessInterface represents passwordless authentication flows. It extends the shared interface with login/verification code helpers.

type AuthSharedInterface added in v0.30.0

type AuthSharedInterface interface {
	// Router returns an HTTP mux that serves all auth routes.
	Router() *http.ServeMux

	IsRegistrationEnabled() bool
	IsPasswordless() bool
	IsVerificationEnabled() bool

	// Middlewares for protecting or enriching routes.
	WebAuthOrRedirectMiddleware(next http.Handler) http.Handler
	// ApiAuthOrErrorMiddleware(next http.Handler) http.Handler
	WebAppendUserIdIfExistsMiddleware(next http.Handler) http.Handler

	// Current user lookup from the request context.
	GetCurrentUserID(r *http.Request) string

	// Web URL helpers
	LinkLogin() string
	LinkLogout() string
	LinkRegister() string
	LinkRegisterCodeVerify() string
	LinkRedirectOnSuccess() string

	// API URL helpers
	LinkApiLogin() string
	LinkApiLogout() string
	LinkApiRegister() string
	LinkApiRegisterCodeVerify() string
	LinkApiImpersonateStart() string
	LinkApiImpersonateStop() string

	GetEndpoint() string
	SetEndpoint(endpoint string)

	GetLogger() *slog.Logger
	SetLogger(logger *slog.Logger)

	GetLayout() func(content string) string
	SetLayout(layout func(content string) string)

	GetFuncTemporaryKeyGet() func(key string) (string, error)
	SetFuncTemporaryKeyGet(fn func(key string) (string, error))

	GetFuncTemporaryKeySet() func(key string, value string, expiresSeconds int) error
	SetFuncTemporaryKeySet(fn func(key string, value string, expiresSeconds int) error)

	GetUseCookies() bool
	SetUseCookies(useCookies bool)

	GetCookieName() string
	SetCookieName(name string)

	GetFuncUserFindByAuthToken() func(ctx context.Context, token string, options UserAuthOptions) (userID string, err error)
	SetFuncUserFindByAuthToken(fn func(ctx context.Context, token string, options UserAuthOptions) (userID string, err error))

	// Additional accessors used by internal API flows.
	GetDisableRateLimit() bool
	SetDisableRateLimit(disable bool)

	GetPasswordStrength() *PasswordStrengthConfig
	SetPasswordStrength(cfg *PasswordStrengthConfig)

	GetFuncUserLogin() func(ctx context.Context, username, password string, options UserAuthOptions) (string, error)
	SetFuncUserLogin(fn func(ctx context.Context, username, password string, options UserAuthOptions) (string, error))

	GetPasswordlessUserRegister() func(ctx context.Context, email, firstName, lastName string, options UserAuthOptions) error
	SetPasswordlessUserRegister(fn func(ctx context.Context, email, firstName, lastName string, options UserAuthOptions) error)

	GetFuncUserRegister() func(ctx context.Context, username, password, firstName, lastName string, options UserAuthOptions) error
	SetFuncUserRegister(fn func(ctx context.Context, username, password, firstName, lastName string, options UserAuthOptions) error)

	GetFuncUserPasswordChange() func(ctx context.Context, userID, password string, options UserAuthOptions) error
	SetFuncUserPasswordChange(fn func(ctx context.Context, userID, password string, options UserAuthOptions) error)

	GetFuncUserLogout() func(ctx context.Context, userID string, options UserAuthOptions) error
	SetFuncUserLogout(fn func(ctx context.Context, userID string, options UserAuthOptions) error)

	GetPasswordlessUserFindByEmail() func(ctx context.Context, email string, options UserAuthOptions) (string, error)
	SetPasswordlessUserFindByEmail(fn func(ctx context.Context, email string, options UserAuthOptions) (string, error))

	GetFuncUserFindByUsername() func(ctx context.Context, username, firstName, lastName string, options UserAuthOptions) (string, error)
	SetFuncUserFindByUsername(fn func(ctx context.Context, username, firstName, lastName string, options UserAuthOptions) (string, error))

	GetFuncEmailTemplatePasswordRestore() func(ctx context.Context, userID string, passwordRestoreLink string, options UserAuthOptions) string
	SetFuncEmailTemplatePasswordRestore(fn func(ctx context.Context, userID string, passwordRestoreLink string, options UserAuthOptions) string)

	GetFuncEmailTemplateRegisterCode() func(ctx context.Context, email string, registerLink string, options UserAuthOptions) string
	SetFuncEmailTemplateRegisterCode(fn func(ctx context.Context, email string, registerLink string, options UserAuthOptions) string)

	GetFuncEmailSend() func(ctx context.Context, userID, emailSubject, emailBody string) error
	SetFuncEmailSend(fn func(ctx context.Context, userID, emailSubject, emailBody string) error)

	GetPasswordlessFuncEmailTemplateLoginCode() func(ctx context.Context, email string, loginLink string, options UserAuthOptions) string
	SetPasswordlessFuncEmailTemplateLoginCode(fn func(ctx context.Context, email string, loginLink string, options UserAuthOptions) string)

	GetPasswordlessFuncEmailTemplateRegisterCode() func(ctx context.Context, email string, registerLink string, options UserAuthOptions) string
	SetPasswordlessFuncEmailTemplateRegisterCode(fn func(ctx context.Context, email string, registerLink string, options UserAuthOptions) string)

	GetPasswordlessFuncEmailSend() func(ctx context.Context, email string, emailSubject, emailBody string) error
	SetPasswordlessFuncEmailSend(fn func(ctx context.Context, email string, emailSubject, emailBody string) error)

	GetFuncUserStoreAuthToken() func(ctx context.Context, token, userID string, options UserAuthOptions) error
	SetFuncUserStoreAuthToken(fn func(ctx context.Context, token, userID string, options UserAuthOptions) error)

	SetAuthCookie(w http.ResponseWriter, r *http.Request, token string)
	RemoveAuthCookie(w http.ResponseWriter, r *http.Request)

	// Observability hooks for metrics and tracing (optional).
	GetObservabilityHooks() ObservabilityHooks
	SetObservabilityHooks(hooks ObservabilityHooks)

	// Final authentication step helpers used by internal API flows.
	AuthenticateViaUsername(w http.ResponseWriter, r *http.Request, email, firstName, lastName string)

	IsImpersonationEnabled() bool

	GetFuncCanImpersonate() func(ctx context.Context, adminUserID string, targetUserID string) (bool, error)
	SetFuncCanImpersonate(fn func(ctx context.Context, adminUserID string, targetUserID string) (bool, error))

	GetFuncImpersonationStart() func(ctx context.Context, adminUserID string, targetUserID string) error
	SetFuncImpersonationStart(fn func(ctx context.Context, adminUserID string, targetUserID string) error)

	GetFuncImpersonationStop() func(ctx context.Context, adminUserID string, targetUserID string) error
	SetFuncImpersonationStop(fn func(ctx context.Context, adminUserID string, targetUserID string) error)
}

AuthSharedInterface defines the common behavior shared by all auth modes. It includes routing helpers, middleware, current user access, and the primary login/register URL helpers.

type AuthenticatedUserID added in v0.30.0

type AuthenticatedUserID struct{}

type ConfigAuthKnight added in v0.35.0

type ConfigAuthKnight struct {
	ConfigShared
	ConfigRateLimiting
	ConfigCSRF
	ConfigImpersonation

	// FuncUserFindByEmail finds a user by email and returns their ID.
	// Required.
	FuncUserFindByEmail func(ctx context.Context, email string, options UserAuthOptions) (userID string, err error)

	// FuncUserRegister creates a new user with email, first name, and last name.
	// The email is already verified by AuthKnight — no verification step needed.
	// Called when the user submits the register form (first name + last name).
	// Required.
	FuncUserRegister func(ctx context.Context, email string, firstName string, lastName string, options UserAuthOptions) (userID string, err error)

	// FuncRedirectURL calculates the redirect URL after successful auth.
	// If nil, falls back to UrlRedirectOnSuccess.
	FuncRedirectURL func(ctx context.Context, userID string) string

	// HTTPTimeout for calls to the AuthKnight API. Defaults to 10 seconds.
	HTTPTimeout time.Duration
}

ConfigAuthKnight contains configuration for AuthKnight-based authentication. It embeds the shared config structs and adds AuthKnight-specific callbacks.

type ConfigCSRF added in v0.35.0

type ConfigCSRF struct {
	EnableCSRFProtection bool
	CSRFSecret           string
}

ConfigCSRF contains CSRF protection options.

type ConfigImpersonation added in v0.35.0

type ConfigImpersonation struct {
	EnableImpersonation    bool
	FuncCanImpersonate     func(ctx context.Context, adminUserID string, targetUserID string) (bool, error)
	FuncImpersonationStart func(ctx context.Context, adminUserID string, targetUserID string) error
	FuncImpersonationStop  func(ctx context.Context, adminUserID string, targetUserID string) error
}

ConfigImpersonation contains impersonation options.

type ConfigPasswordless added in v0.30.0

type ConfigPasswordless struct {
	ConfigShared
	ConfigRateLimiting
	ConfigCSRF
	ConfigImpersonation

	// ===== START: passwordless options
	FuncUserFindByEmail           func(ctx context.Context, email string, options UserAuthOptions) (userID string, err error)
	FuncEmailTemplateLoginCode    func(ctx context.Context, email string, loginLink string, options UserAuthOptions) string    // optional
	FuncEmailTemplateRegisterCode func(ctx context.Context, email string, registerLink string, options UserAuthOptions) string // optional
	FuncEmailSend                 func(ctx context.Context, email string, emailSubject string, emailBody string) (err error)
	FuncUserRegister              func(ctx context.Context, email string, firstName string, lastName string, options UserAuthOptions) (err error)
}

type ConfigRateLimiting added in v0.35.0

type ConfigRateLimiting struct {
	DisableRateLimit   bool
	FuncCheckRateLimit func(ip string, endpoint string) (allowed bool, retryAfter time.Duration, err error)
	MaxLoginAttempts   int
	LockoutDuration    time.Duration
}

ConfigRateLimiting contains rate limiting options.

type ConfigShared added in v0.35.0

type ConfigShared struct {
	EnableRegistration      bool
	Endpoint                string
	FuncLayout              func(content string) string
	FuncTemporaryKeyGet     func(key string) (value string, err error)
	FuncTemporaryKeySet     func(key string, value string, expiresSeconds int) (err error)
	FuncUserStoreAuthToken  func(ctx context.Context, sessionID string, userID string, options UserAuthOptions) error
	FuncUserFindByAuthToken func(ctx context.Context, sessionID string, options UserAuthOptions) (userID string, err error)
	FuncUserLogout          func(ctx context.Context, userID string, options UserAuthOptions) (err error)
	UrlRedirectOnSuccess    string
	UseCookies              bool
	UseLocalStorage         bool
	CookieConfig            *CookieConfig
	Logger                  *slog.Logger
	ObservabilityHooks      ObservabilityHooks
}

ConfigShared contains fields common to all auth modes.

type ConfigUsernameAndPassword added in v0.30.0

type ConfigUsernameAndPassword struct {
	ConfigShared
	ConfigRateLimiting
	ConfigCSRF
	ConfigImpersonation

	// ===== START: username(email) and password options
	EnableVerification               bool
	FuncEmailTemplatePasswordRestore func(ctx context.Context, userID string, passwordRestoreLink string, options UserAuthOptions) string // optional
	FuncEmailTemplateRegisterCode    func(ctx context.Context, userID string, registerLink string, options UserAuthOptions) string        // optional
	FuncEmailSend                    func(ctx context.Context, userID string, emailSubject string, emailBody string) (err error)
	FuncUserFindByUsername           func(ctx context.Context, username string, firstName string, lastName string, options UserAuthOptions) (userID string, err error)
	FuncUserLogin                    func(ctx context.Context, username string, password string, options UserAuthOptions) (userID string, err error)
	FuncUserPasswordChange           func(ctx context.Context, username string, newPassword string, options UserAuthOptions) (err error)
	FuncUserRegister                 func(ctx context.Context, username string, password string, firstName string, lastName string, options UserAuthOptions) (err error)
	PasswordStrength                 *PasswordStrengthConfig
	LabelUsername                    string
}

Config defines the available configuration options for authentication

type CookieConfig added in v0.30.0

type CookieConfig struct {
	Name     string
	HttpOnly string
	Secure   string
	SameSite http.SameSite
	MaxAge   int
	Domain   string
	Path     string
}

type CookieOption added in v0.33.0

type CookieOption func(*CookieConfig)

CookieOption customizes a CookieConfig by mutating it. Options are applied on top of the default config.

func WithCookieConfig added in v0.33.0

func WithCookieConfig(cfg CookieConfig) CookieOption

WithCookieConfig replaces the entire cookie config with the provided one. Use this when you already have a complete CookieConfig.

func WithCookieName added in v0.34.0

func WithCookieName(name string) CookieOption

WithCookieName sets the cookie name.

func WithDomain added in v0.33.0

func WithDomain(domain string) CookieOption

WithDomain sets the Domain.

func WithHttpOnly added in v0.33.0

func WithHttpOnly(httpOnly bool) CookieOption

WithHttpOnly sets the HttpOnly flag. Pass true for CookieHttpOnly, false for CookieHttpWritable.

func WithMaxAge added in v0.33.0

func WithMaxAge(maxAge int) CookieOption

WithMaxAge sets the MaxAge in seconds.

func WithPath added in v0.33.0

func WithPath(path string) CookieOption

WithPath sets the Path.

func WithSameSite added in v0.33.0

func WithSameSite(sameSite http.SameSite) CookieOption

WithSameSite sets the SameSite attribute.

func WithSecure added in v0.33.0

func WithSecure(secure bool) CookieOption

WithSecure sets the Secure flag. Pass true for CookieSecure, false for CookieInsecure.

type ImpersonatorUserID added in v0.33.0

type ImpersonatorUserID struct{}

type IsImpersonating added in v0.33.0

type IsImpersonating struct{}

type NoopObservabilityHooks added in v0.31.0

type NoopObservabilityHooks struct{}

NoopObservabilityHooks is a no-op implementation of ObservabilityHooks. It is the default when no hooks are configured.

func (NoopObservabilityHooks) RecordImpersonationStart added in v0.33.0

func (NoopObservabilityHooks) RecordImpersonationStart(string, string)

func (NoopObservabilityHooks) RecordImpersonationStop added in v0.33.0

func (NoopObservabilityHooks) RecordImpersonationStop(string, string)

func (NoopObservabilityHooks) RecordLoginAttempt added in v0.31.0

func (NoopObservabilityHooks) RecordLoginAttempt(string, bool, error)

func (NoopObservabilityHooks) RecordPasswordReset added in v0.31.0

func (NoopObservabilityHooks) RecordPasswordReset(bool, error)

func (NoopObservabilityHooks) RecordRateLimitHit added in v0.31.0

func (NoopObservabilityHooks) RecordRateLimitHit(string, string)

func (NoopObservabilityHooks) RecordRegistrationAttempt added in v0.31.0

func (NoopObservabilityHooks) RecordRegistrationAttempt(bool, error)

func (NoopObservabilityHooks) RecordSessionCreated added in v0.31.0

func (NoopObservabilityHooks) RecordSessionCreated(string)

type ObservabilityHooks added in v0.31.0

type ObservabilityHooks interface {
	// RecordLoginAttempt is called after every login attempt (success or
	// failure). method is "password" or "passwordless". err is nil on
	// success.
	RecordLoginAttempt(method string, success bool, err error)

	// RecordRegistrationAttempt is called after every registration attempt.
	// err is nil on success.
	RecordRegistrationAttempt(success bool, err error)

	// RecordRateLimitHit is called when a request is denied due to rate
	// limiting.
	RecordRateLimitHit(endpoint string, ip string)

	// RecordSessionCreated is called when a new session/token is issued
	// for a user.
	RecordSessionCreated(userID string)

	// RecordPasswordReset is called after a password reset attempt.
	// err is nil on success.
	RecordPasswordReset(success bool, err error)

	// RecordImpersonationStart is called when an admin begins impersonating
	// another user.
	RecordImpersonationStart(adminUserID string, targetUserID string)

	// RecordImpersonationStop is called when an admin stops impersonating
	// another user.
	RecordImpersonationStop(adminUserID string, targetUserID string)
}

ObservabilityHooks allows applications to record metrics and tracing spans for authentication events using their preferred provider (Prometheus, Datadog, OpenTelemetry, etc.).

All methods must be safe to call from multiple goroutines. Implementations should be non-blocking; if a method needs to do expensive work it should do so asynchronously.

A nil ObservabilityHooks is valid and means no metrics are recorded.

type PasswordStrengthConfig

type PasswordStrengthConfig struct {
	MinLength         int
	RequireUppercase  bool
	RequireLowercase  bool
	RequireDigit      bool
	RequireSpecial    bool
	ForbidCommonWords bool
}

PasswordStrengthConfig defines configurable rules for password strength.

type UserAuthOptions added in v0.30.0

type UserAuthOptions struct {
	UserIp    string
	UserAgent string
}

Jump to

Keyboard shortcuts

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