Documentation
¶
Overview ¶
Package config defines global configuration options and functional option helpers for the Auth engine.
Index ¶
- type Config
- type Option
- func WithAfterCreateSession(fns ...plugin.AfterCreateSessionFunc) Option
- func WithAfterSignIn(fns ...plugin.AfterSignInFunc) Option
- func WithAfterSignUp(fns ...plugin.AfterSignUpFunc) Option
- func WithAsyncHooks(async bool) Option
- func WithBcryptCost(cost int) Option
- func WithBeforeCreateSession(fns ...plugin.BeforeCreateSessionFunc) Option
- func WithBeforeSignIn(fns ...plugin.BeforeSignInFunc) Option
- func WithBeforeSignUp(fns ...plugin.BeforeSignUpFunc) Option
- func WithHooks(hooks *plugin.Hooks) Option
- func WithInterceptor(interceptors ...any) Option
- func WithPlugins(plugins ...plugin.Plugin) Option
- func WithSessionConfig(cfg SessionConfig) Option
- func WithSessionRepository(repo repository.SessionRepository) Option
- type SessionConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
BcryptCost int
Plugins []plugin.Plugin
SessionRepository repository.SessionRepository
SessionConfig SessionConfig
Interceptors []any
Hooks *plugin.Hooks
AsyncHooks bool
}
Config holds the main settings used when constructing an Auth instance.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config initialized with sensible default values.
type Option ¶
type Option func(*Config)
Option represents a functional configuration option for Auth.
func WithAfterCreateSession ¶ added in v1.0.0
func WithAfterCreateSession(fns ...plugin.AfterCreateSessionFunc) Option
WithAfterCreateSession registers functional interceptors executed after session creation.
func WithAfterSignIn ¶ added in v1.0.0
func WithAfterSignIn(fns ...plugin.AfterSignInFunc) Option
WithAfterSignIn registers functional interceptors executed after successful user sign-in.
func WithAfterSignUp ¶ added in v1.0.0
func WithAfterSignUp(fns ...plugin.AfterSignUpFunc) Option
WithAfterSignUp registers functional interceptors executed after user registration.
func WithAsyncHooks ¶ added in v1.0.0
WithAsyncHooks toggles whether lifecycle hooks are dispatched asynchronously.
func WithBcryptCost ¶
WithBcryptCost sets a custom bcrypt cost for password hashing.
func WithBeforeCreateSession ¶ added in v1.0.0
func WithBeforeCreateSession(fns ...plugin.BeforeCreateSessionFunc) Option
WithBeforeCreateSession registers functional interceptors executed before session creation.
func WithBeforeSignIn ¶ added in v1.0.0
func WithBeforeSignIn(fns ...plugin.BeforeSignInFunc) Option
WithBeforeSignIn registers functional interceptors executed before user sign-in.
func WithBeforeSignUp ¶ added in v1.0.0
func WithBeforeSignUp(fns ...plugin.BeforeSignUpFunc) Option
WithBeforeSignUp registers functional interceptors executed before user registration.
func WithHooks ¶ added in v1.0.0
WithHooks configures a custom lifecycle hooks instance into the Auth engine.
func WithInterceptor ¶ added in v1.0.0
WithInterceptor registers one or more structured or functional interceptors into the Auth engine pipeline.
func WithPlugins ¶
WithPlugins registers one or more modular authentication plugins into the Auth engine.
func WithSessionConfig ¶ added in v1.0.0
func WithSessionConfig(cfg SessionConfig) Option
WithSessionConfig sets custom session lifetime and behavioral configuration.
func WithSessionRepository ¶ added in v1.0.0
func WithSessionRepository(repo repository.SessionRepository) Option
WithSessionRepository configures the persistent storage repository for authentication sessions.
type SessionConfig ¶ added in v1.0.0
type SessionConfig struct {
// DefaultDuration specifies the standard validity lifetime for issued sessions (default: 24h).
DefaultDuration time.Duration
// RememberMeDuration specifies the extended validity lifetime when RememberMe is requested (default: 30 days).
RememberMeDuration time.Duration
// CookieName specifies the session cookie identifier (default: "auth_session").
CookieName string
}
SessionConfig defines session lifetime, renewal, and cookie configuration.
func DefaultSessionConfig ¶ added in v1.0.0
func DefaultSessionConfig() SessionConfig
DefaultSessionConfig returns sensible default session settings (24h default, 30-day remember me).