config

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PasswordMinimumLengthFloor = 8
	PasswordMaximumLength      = 128

	PasskeyCloneResponseAlert             = "alert"
	PasskeyCloneResponseRestrict          = "restrict"
	PasskeyCloneResponseRestrictAndRevoke = "restrict_and_revoke"
)
View Source
const (
	AccessTokenRevocationModeImmediate = "immediate"
	AccessTokenRevocationModeExpiry    = "expiry"

	// ExpiryOnlyMaxAccessTokenTTL bounds the period during which a token can
	// remain usable after its backing session or authorization is revoked.
	ExpiryOnlyMaxAccessTokenTTL = 10 * time.Minute

	// MaxAccessTokenTTL is the longest access-token lifetime supported by any
	// revocation mode. Immediate-mode markers are retained for at least this
	// long so they also cover tokens issued before a policy reduction.
	MaxAccessTokenTTL = 24 * time.Hour
)
View Source
const (
	OrgModePersonal = "personal"
	OrgModeSingle   = "single"
	OrgModeMulti    = "multi"
)
View Source
const (
	SecurityEventSelectionAll      = "all"
	SecurityEventSelectionNone     = "none"
	SecurityEventSelectionStandard = "standard"
)
View Source
const (
	DefaultAppName = "Authara"
)
View Source
const DefaultReconcileInterval = 2 * time.Second

Variables

View Source
var (
	ErrUnknownSetting   = errors.New("unknown runtime setting")
	ErrSettingLocked    = errors.New("runtime setting is locked")
	ErrRevisionConflict = configruntime.ErrRevisionConflict
	ErrInvalidValue     = errors.New("invalid runtime setting value")
	ErrMissingActor     = errors.New("runtime setting actor is missing")
)

Functions

This section is empty.

Types

type AccessPolicy added in v0.1.10

type AccessPolicy struct {
	AllowedEmailEnabled bool `env:"AUTHARA_ACCESS_POLICY_ALLOWLIST_ENABLED,default=false"`
}

type Admin added in v0.1.23

type Admin struct {
	AuditRetentionDays   int           `env:"AUTHARA_ADMIN_AUDIT_RETENTION_DAYS,default=180"`
	AuditCleanupInterval time.Duration `env:"AUTHARA_ADMIN_AUDIT_CLEANUP_INTERVAL,default=24h"`
}

type AdminPolicy added in v0.21.0

type AdminPolicy struct {
	AuditRetention time.Duration
}

type AdminPolicyReader added in v0.21.0

type AdminPolicyReader interface {
	CurrentAdmin() AdminPolicy
}

type AdminPolicyReaderFunc added in v0.21.0

type AdminPolicyReaderFunc func() AdminPolicy

func (AdminPolicyReaderFunc) CurrentAdmin added in v0.21.0

func (f AdminPolicyReaderFunc) CurrentAdmin() AdminPolicy

type AllowlistPolicy added in v0.21.0

type AllowlistPolicy struct {
	AllowlistEnabled bool
}

type AllowlistPolicyReader added in v0.21.0

type AllowlistPolicyReader interface {
	CurrentAllowlist() AllowlistPolicy
}

type AllowlistPolicyReaderFunc added in v0.21.0

type AllowlistPolicyReaderFunc func() AllowlistPolicy

func (AllowlistPolicyReaderFunc) CurrentAllowlist added in v0.21.0

func (f AllowlistPolicyReaderFunc) CurrentAllowlist() AllowlistPolicy

type Authentication added in v0.17.0

type Authentication struct {
	UsernameLoginEnabled      bool   `env:"AUTHARA_USERNAME_LOGIN_ENABLED,default=false"`
	EmailVerificationRequired bool   `env:"AUTHARA_EMAIL_VERIFICATION_REQUIRED,default=false"`
	PasswordMinimumLength     int    `env:"AUTHARA_PASSWORD_MIN_LENGTH,default=8"`
	PasskeyCloneResponse      string `env:"AUTHARA_PASSKEY_CLONE_RESPONSE,default=alert"`
	PasskeyCloneNotifyUser    bool   `env:"AUTHARA_PASSKEY_CLONE_NOTIFY_USER,default=true"`
}

type AuthenticationPolicy added in v0.21.0

type AuthenticationPolicy struct {
	UsernameLoginEnabled      bool
	EmailVerificationRequired bool
	PasskeyCloneResponse      string
	PasskeyCloneNotifyUser    bool
}

type AuthenticationPolicyReader added in v0.21.0

type AuthenticationPolicyReader interface {
	CurrentAuthentication() AuthenticationPolicy
}

type AuthenticationPolicyReaderFunc added in v0.21.0

type AuthenticationPolicyReaderFunc func() AuthenticationPolicy

func (AuthenticationPolicyReaderFunc) CurrentAuthentication added in v0.21.0

func (f AuthenticationPolicyReaderFunc) CurrentAuthentication() AuthenticationPolicy

type Cache added in v0.1.21

type Cache struct {
	Provider                  string `env:"AUTHARA_CACHE_PROVIDER,default=noop"`
	AccessTokenRevocationMode string `env:"AUTHARA_ACCESS_TOKEN_REVOCATION_MODE"`
	RedisHost                 string `env:"AUTHARA_REDIS_HOST,default=localhost"`
	RedisPort                 int    `env:"AUTHARA_REDIS_PORT,default=6379"`
	RedisPassword             string `env:"AUTHARA_REDIS_PASSWORD"`
	RedisDB                   int    `env:"AUTHARA_REDIS_DB,default=0"`
}

type Challenge added in v0.1.12

type Challenge struct {
	Enabled             bool          `env:"AUTHARA_CHALLENGE_ENABLED,default=false"`
	TTL                 time.Duration `env:"AUTHARA_CHALLENGE_TTL,default=30m"`
	VerificationCodeTTL time.Duration `env:"AUTHARA_CHALLENGE_VERIFICATION_CODE_TTL,default=10m"`
	MaxAttempts         int           `env:"AUTHARA_CHALLENGE_MAX_ATTEMPTS,default=5"`
	MaxResends          int           `env:"AUTHARA_CHALLENGE_MAX_RESENDS,default=3"`
	MinResendInterval   time.Duration `env:"AUTHARA_CHALLENGE_MIN_RESEND_INTERVAL,default=30s"`
}

type ChallengePolicy added in v0.21.0

type ChallengePolicy struct {
	Enabled               bool
	TTL                   time.Duration
	VerificationCodeTTL   time.Duration
	MaxAttempts           int
	MaxResends            int
	MinimumResendInterval time.Duration
}

ChallengePolicy is published as one immutable value so an operation cannot observe a mixture of revisions while reading related settings.

type ChallengePolicyReader added in v0.21.0

type ChallengePolicyReader interface {
	CurrentChallenge() ChallengePolicy
}

type Config

type Config struct {
	Values         Values
	DB             DB
	Cache          Cache
	Logging        Logging
	Observability  Observability
	UI             UI
	OAuth          OAuth
	Token          Token
	Session        Session
	RateLimit      RateLimit
	Webhook        Webhook
	AccessPolicy   AccessPolicy
	Admin          Admin
	OperatorAudit  OperatorAudit
	InternalAPI    InternalAPI
	Organization   Organization
	Authentication Authentication
	SecurityEvents SecurityEvents
	Challenge      Challenge
	Email          Email
}

func Load

func Load() (*Config, error)

type Control added in v0.21.0

type Control string
const (
	ControlEnvironment Control = "environment"
	ControlOperator    Control = "operator"
	ControlHybrid      Control = "hybrid"
)

type DB

type DB struct {
	Host        string `env:"POSTGRESQL_HOST,required"`
	Port        int    `env:"POSTGRESQL_PORT,required"`
	Username    string `env:"POSTGRESQL_USERNAME,required"`
	Password    string `env:"POSTGRESQL_PASSWORD,required"`
	Database    string `env:"POSTGRESQL_DATABASE,required"`
	Timezone    string `env:"POSTGRESQL_TIMEZONE,default=UTC"`
	LogSQL      bool   `env:"POSTGRESQL_LOG_SQL,default=false"`
	SSLMode     string `env:"POSTGRESQL_SSL_MODE,default=disable"`
	SSLRootCert string `env:"POSTGRESQL_SSL_ROOT_CERT"`

	MaxOpenConns    int           `env:"AUTHARA_DB_MAX_OPEN_CONNS,default=40"`
	MaxIdleConns    int           `env:"AUTHARA_DB_MAX_IDLE_CONNS,default=20"`
	ConnMaxLifetime time.Duration `env:"AUTHARA_DB_CONN_MAX_LIFETIME,default=30m"`
	ConnMaxIdleTime time.Duration `env:"AUTHARA_DB_CONN_MAX_IDLE_TIME,default=5m"`
}

type Definition added in v0.21.0

type Definition struct {
	Key          Key
	Name         string
	Description  string
	Environment  string
	Control      Control
	Reload       Reload
	Sensitive    bool
	Group        string
	Type         ValueType
	DefaultValue string
	Required     bool
	HasDefault   bool
	Minimum      string
	Maximum      string
	Allowed      []string
	Impact       string
	// contains filtered or unexported fields
}

func LookupDefinition added in v0.21.0

func LookupDefinition(key Key) (Definition, bool)

type Description added in v0.21.0

type Description struct {
	Definition
	EffectiveValue    string
	EffectiveSource   Source
	Locked            bool
	PersistedOverride *string
	Revision          int64
	DormantOverride   bool
}

type Email added in v0.1.12

type Email struct {
	Provider string `env:"AUTHARA_EMAIL_PROVIDER,default=noop"`
	From     string `env:"AUTHARA_EMAIL_FROM"`

	SMTPHost     string        `env:"AUTHARA_EMAIL_SMTP_HOST"`
	SMTPPort     int           `env:"AUTHARA_EMAIL_SMTP_PORT,default=587"`
	SMTPUsername string        `env:"AUTHARA_EMAIL_SMTP_USERNAME"`
	SMTPPassword string        `env:"AUTHARA_EMAIL_SMTP_PASSWORD"`
	SMTPTLS      bool          `env:"AUTHARA_EMAIL_SMTP_TLS,default=true"`
	SMTPTimeout  time.Duration `env:"AUTHARA_EMAIL_SMTP_TIMEOUT,default=10s"`

	WorkerCount          int           `env:"AUTHARA_EMAIL_WORKER_COUNT,default=2"`
	WorkerPollInterval   time.Duration `env:"AUTHARA_EMAIL_WORKER_POLL_INTERVAL,default=2s"`
	JobMaxAttempts       int           `env:"AUTHARA_EMAIL_JOB_MAX_ATTEMPTS,default=100"`
	ProcessingStaleAfter time.Duration `env:"AUTHARA_EMAIL_PROCESSING_STALE_AFTER,default=2m"`
	StaleReaperInterval  time.Duration `env:"AUTHARA_EMAIL_STALE_REAPER_INTERVAL,default=1m"`
	MaintenanceBatchSize int           `env:"AUTHARA_EMAIL_MAINTENANCE_BATCH_SIZE,default=1000"`
	CleanupSentAfter     time.Duration `env:"AUTHARA_EMAIL_CLEANUP_SENT_AFTER,default=720h"`    // 30d
	CleanupFailedAfter   time.Duration `env:"AUTHARA_EMAIL_CLEANUP_FAILED_AFTER,default=2160h"` // 90d
	CleanupInterval      time.Duration `env:"AUTHARA_EMAIL_CLEANUP_INTERVAL,default=1h"`
}

func (Email) IsDeliverable added in v0.22.0

func (e Email) IsDeliverable() bool

IsDeliverable reports whether the configured provider can deliver email to recipients. The noop provider is a development sink and is not suitable for user-facing flows such as password recovery.

type EmailPolicy added in v0.21.0

type EmailPolicy struct {
	JobMaxAttempts     int
	CleanupSentAfter   time.Duration
	CleanupFailedAfter time.Duration
}

type EmailPolicyReader added in v0.21.0

type EmailPolicyReader interface {
	CurrentEmail() EmailPolicy
}

type EmailPolicyReaderFunc added in v0.21.0

type EmailPolicyReaderFunc func() EmailPolicy

func (EmailPolicyReaderFunc) CurrentEmail added in v0.21.0

func (f EmailPolicyReaderFunc) CurrentEmail() EmailPolicy

type EnvironmentVariable added in v0.21.0

type EnvironmentVariable struct {
	Name        string
	DisplayName string
	Group       string
	Type        string
	Default     string
	Required    bool
	HasDefault  bool
	Sensitive   bool
}

EnvironmentVariable describes one environment variable consumed by Config. The catalog is derived from the same struct tags used by go-envconfig so new variables cannot silently disappear from the operator settings overview.

func EnvironmentVariables added in v0.21.0

func EnvironmentVariables() []EnvironmentVariable

EnvironmentVariables returns every environment variable in declaration order, grouped by the top-level Config section that owns it.

type InternalAPI added in v0.1.24

type InternalAPI struct {
	Token string `env:"AUTHARA_INTERNAL_API_TOKEN"`
}

type Key added in v0.21.0

type Key = configruntime.Key
const (
	KeyUIAppName         Key = "ui.app_name"
	KeyUIDefaultReturnTo Key = "ui.default_return_to"

	KeyAuthenticationUsernameLoginEnabled      Key = "authentication.username_login_enabled"
	KeyAuthenticationEmailVerificationRequired Key = "authentication.email_verification_required"
	KeyAuthenticationPasskeyCloneResponse      Key = "authentication.passkey_clone_response"
	KeyAuthenticationPasskeyCloneNotifyUser    Key = "authentication.passkey_clone_notify_user"

	KeyTokenAccessTTL Key = "token.access_ttl"

	KeySessionTTL                         Key = "session.ttl"
	KeySessionRefreshTokenTTL             Key = "session.refresh_token_ttl"
	KeySessionRotation                    Key = "session.refresh_token_rotation"
	KeySessionRecentAuthenticationEnabled Key = "session.recent_authentication_enabled"
	KeySessionRecentAuthenticationWindow  Key = "session.recent_authentication_window"

	KeyOrganizationPublicManagementEnabled Key = "organization.public_management_enabled"
	KeyOrganizationInvitationTTL           Key = "organization.invitation_ttl"

	KeyAccessPolicyAllowlistEnabled Key = "access_policy.allowlist_enabled"

	KeyAdminAuditRetention Key = "admin.audit_retention"

	KeyEmailJobMaxAttempts     Key = "email.job_max_attempts"
	KeyEmailCleanupSentAfter   Key = "email.cleanup_sent_after"
	KeyEmailCleanupFailedAfter Key = "email.cleanup_failed_after"

	KeyWebhookEnabledEvents        Key = "webhook.enabled_events"
	KeyWebhookTimeout              Key = "webhook.timeout"
	KeyWebhookMaxDeliveryAttempts  Key = "webhook.max_delivery_attempts"
	KeyWebhookProcessingStaleAfter Key = "webhook.processing_stale_after"
	KeyWebhookDeliveredRetention   Key = "webhook.delivered_retention"
	KeyWebhookFailedRetention      Key = "webhook.failed_retention"
	KeyWebhookMaintenanceBatchSize Key = "webhook.maintenance_batch_size"

	KeyChallengeEnabled               Key = "challenge.enabled"
	KeyChallengeTTL                   Key = "challenge.ttl"
	KeyChallengeVerificationCodeTTL   Key = "challenge.verification_code_ttl"
	KeyChallengeMaxAttempts           Key = "challenge.max_attempts"
	KeyChallengeMaxResends            Key = "challenge.max_resends"
	KeyChallengeMinimumResendInterval Key = "challenge.minimum_resend_interval"

	KeyRateLimitLoginIPLimit             Key = "rate_limit.login.ip.limit"
	KeyRateLimitLoginIPWindow            Key = "rate_limit.login.ip.window"
	KeyRateLimitLoginEmailLimit          Key = "rate_limit.login.email.limit"
	KeyRateLimitLoginEmailWindow         Key = "rate_limit.login.email.window"
	KeyRateLimitSignupIPLimit            Key = "rate_limit.signup.ip.limit"
	KeyRateLimitSignupIPWindow           Key = "rate_limit.signup.ip.window"
	KeyRateLimitSignupEmailLimit         Key = "rate_limit.signup.email.limit"
	KeyRateLimitSignupEmailWindow        Key = "rate_limit.signup.email.window"
	KeyRateLimitPasswordResetIPLimit     Key = "rate_limit.password_reset.ip.limit"
	KeyRateLimitPasswordResetIPWindow    Key = "rate_limit.password_reset.ip.window"
	KeyRateLimitPasswordResetEmailLimit  Key = "rate_limit.password_reset.email.limit"
	KeyRateLimitPasswordResetEmailWindow Key = "rate_limit.password_reset.email.window"
	KeyRateLimitPasskeyLoginIPLimit      Key = "rate_limit.passkey_login.ip.limit"
	KeyRateLimitPasskeyLoginIPWindow     Key = "rate_limit.passkey_login.ip.window"
	KeyRateLimitChallengeVerifyIPLimit   Key = "rate_limit.challenge_verify.ip.limit"
	KeyRateLimitChallengeVerifyIPWindow  Key = "rate_limit.challenge_verify.ip.window"
	KeyRateLimitChallengeResendIPLimit   Key = "rate_limit.challenge_resend.ip.limit"
	KeyRateLimitChallengeResendIPWindow  Key = "rate_limit.challenge_resend.ip.window"
	KeyRateLimitCleanupEvery             Key = "rate_limit.cleanup_every"
	KeyRateLimitMaxEntries               Key = "rate_limit.max_entries"
)

type Logging

type Logging struct {
	Level string `env:"LOG_LEVEL"`
}

type Mutation added in v0.21.0

type Mutation = configruntime.Mutation

type OAuth

type OAuth struct {
	Providers []string `env:"AUTHARA_OAUTH_PROVIDERS"`

	GoogleClientID     string `env:"AUTHARA_OAUTH_GOOGLE_CLIENT_ID"`
	GoogleClientSecret string `env:"AUTHARA_OAUTH_GOOGLE_CLIENT_SECRET"`
	MicrosoftClientID  string `env:"AUTHARA_OAUTH_MICROSOFT_CLIENT_ID"`
	MicrosoftTenantID  string `env:"AUTHARA_OAUTH_MICROSOFT_TENANT_ID"`

	AppleClientID         string            `env:"AUTHARA_OAUTH_APPLE_CLIENT_ID"`
	AppleTeamID           string            `env:"AUTHARA_OAUTH_APPLE_TEAM_ID"`
	AppleKeyID            string            `env:"AUTHARA_OAUTH_APPLE_KEY_ID"`
	ApplePrivateKeyBase64 string            `env:"AUTHARA_OAUTH_APPLE_PRIVATE_KEY_BASE64"`
	AppleTokenActiveKeyID string            `env:"AUTHARA_OAUTH_APPLE_TOKEN_ACTIVE_KEY_ID"`
	AppleTokenKeys        map[string]string `env:"AUTHARA_OAUTH_APPLE_TOKEN_KEYS"`
	ApplePrivateKey       *ecdsa.PrivateKey
	AppleDecodedTokenKeys map[string][]byte
}

type Observability added in v0.19.0

type Observability struct {
	Enabled bool `env:"AUTHARA_METRICS_ENABLED,default=false"`
}

type OperatorAudit added in v0.22.0

type OperatorAudit struct {
	RetentionDays int `env:"AUTHARA_OPERATOR_AUDIT_RETENTION_DAYS,default=180"`
}

type Organization added in v0.1.24

type Organization struct {
	Mode                                string `env:"AUTHARA_ORG_MODE,default=single"`
	PublicOrganizationManagementEnabled bool   `env:"AUTHARA_PUBLIC_ORGANIZATION_MANAGEMENT_ENABLED,default=false"`
	InvitationTTLRaw                    string `env:"AUTHARA_ORGANIZATION_INVITATION_TTL,default=168h"`

	InvitationTTL time.Duration
}

type OrganizationPolicy added in v0.21.0

type OrganizationPolicy struct {
	PublicManagementEnabled bool
	InvitationTTL           time.Duration
}

type OrganizationPolicyReader added in v0.21.0

type OrganizationPolicyReader interface {
	CurrentOrganization() OrganizationPolicy
}

type OrganizationPolicyReaderFunc added in v0.21.0

type OrganizationPolicyReaderFunc func() OrganizationPolicy

func (OrganizationPolicyReaderFunc) CurrentOrganization added in v0.21.0

func (f OrganizationPolicyReaderFunc) CurrentOrganization() OrganizationPolicy

type PersistedOverride added in v0.21.0

type PersistedOverride = configruntime.PersistedOverride

type PersistedState added in v0.21.0

type PersistedState = configruntime.PersistedState

type RateLimit

type RateLimit struct {
	LoginIPLimit        int    `env:"AUTHARA_RATE_LIMIT_LOGIN_IP_LIMIT,default=5"`
	LoginIPWindowRaw    string `env:"AUTHARA_RATE_LIMIT_LOGIN_IP_WINDOW,default=1m"`
	LoginEmailLimit     int    `env:"AUTHARA_RATE_LIMIT_LOGIN_EMAIL_LIMIT,default=10"`
	LoginEmailWindowRaw string `env:"AUTHARA_RATE_LIMIT_LOGIN_EMAIL_WINDOW,default=1h"`

	SignupIPLimit        int    `env:"AUTHARA_RATE_LIMIT_SIGNUP_IP_LIMIT,default=3"`
	SignupIPWindowRaw    string `env:"AUTHARA_RATE_LIMIT_SIGNUP_IP_WINDOW,default=1h"`
	SignupEmailLimit     int    `env:"AUTHARA_RATE_LIMIT_SIGNUP_EMAIL_LIMIT,default=3"`
	SignupEmailWindowRaw string `env:"AUTHARA_RATE_LIMIT_SIGNUP_EMAIL_WINDOW,default=24h"`

	PasswordResetIPLimit        int    `env:"AUTHARA_RATE_LIMIT_PASSWORD_RESET_IP_LIMIT,default=5"`
	PasswordResetIPWindowRaw    string `env:"AUTHARA_RATE_LIMIT_PASSWORD_RESET_IP_WINDOW,default=1h"`
	PasswordResetEmailLimit     int    `env:"AUTHARA_RATE_LIMIT_PASSWORD_RESET_EMAIL_LIMIT,default=3"`
	PasswordResetEmailWindowRaw string `env:"AUTHARA_RATE_LIMIT_PASSWORD_RESET_EMAIL_WINDOW,default=24h"`

	PasskeyLoginIPLimit     int    `env:"AUTHARA_RATE_LIMIT_PASSKEY_LOGIN_IP_LIMIT,default=30"`
	PasskeyLoginIPWindowRaw string `env:"AUTHARA_RATE_LIMIT_PASSKEY_LOGIN_IP_WINDOW,default=10m"`

	ChallengeVerifyIPLimit     int    `env:"AUTHARA_RATE_LIMIT_CHALLENGE_VERIFY_IP_LIMIT,default=30"`
	ChallengeVerifyIPWindowRaw string `env:"AUTHARA_RATE_LIMIT_CHALLENGE_VERIFY_IP_WINDOW,default=10m"`

	ChallengeResendIPLimit     int    `env:"AUTHARA_RATE_LIMIT_CHALLENGE_RESEND_IP_LIMIT,default=10"`
	ChallengeResendIPWindowRaw string `env:"AUTHARA_RATE_LIMIT_CHALLENGE_RESEND_IP_WINDOW,default=1h"`

	CleanupEvery int `env:"AUTHARA_RATE_LIMIT_CLEANUP_EVERY,default=200"`
	MaxEntries   int `env:"AUTHARA_RATE_LIMIT_MAX_ENTRIES,default=50000"`

	LoginIPWindow            time.Duration
	LoginEmailWindow         time.Duration
	SignupIPWindow           time.Duration
	SignupEmailWindow        time.Duration
	PasswordResetIPWindow    time.Duration
	PasswordResetEmailWindow time.Duration
	PasskeyLoginIPWindow     time.Duration
	ChallengeVerifyIPWindow  time.Duration
	ChallengeResendIPWindow  time.Duration
}

type RateLimitPolicy added in v0.21.0

type RateLimitPolicy struct {
	LoginIPLimit     int
	LoginIPWindow    time.Duration
	LoginEmailLimit  int
	LoginEmailWindow time.Duration

	SignupIPLimit     int
	SignupIPWindow    time.Duration
	SignupEmailLimit  int
	SignupEmailWindow time.Duration

	PasswordResetIPLimit     int
	PasswordResetIPWindow    time.Duration
	PasswordResetEmailLimit  int
	PasswordResetEmailWindow time.Duration

	PasskeyLoginIPLimit  int
	PasskeyLoginIPWindow time.Duration

	ChallengeVerifyIPLimit  int
	ChallengeVerifyIPWindow time.Duration

	ChallengeResendIPLimit  int
	ChallengeResendIPWindow time.Duration

	CleanupEvery int
	MaxEntries   int
}

RateLimitPolicy is published atomically so one limiter call observes a consistent set of thresholds, windows, and in-memory safety controls.

type Reload added in v0.21.0

type Reload string
const (
	ReloadStartup Reload = "startup"
	ReloadDynamic Reload = "dynamic"
)

type RuntimeSettingsMetrics added in v0.22.0

type RuntimeSettingsMetrics interface {
	SetRuntimeSettingsRevision(revision int64)
	ObserveRuntimeSettingsReconciliation(result string, duration time.Duration, revision int64)
}

type RuntimeSettingsStore added in v0.21.0

type RuntimeSettingsStore interface {
	LoadRuntimeSettings(context.Context) (PersistedState, error)
	UpsertRuntimeSettingOverride(context.Context, Mutation) (PersistedOverride, error)
	DeleteRuntimeSettingOverride(context.Context, Key, int64, int64, uuid.UUID, json.RawMessage) (int64, error)
}

type SecurityEvents added in v0.22.0

type SecurityEvents struct {
	EnabledEvents   []string      `env:"AUTHARA_SECURITY_EVENT_ENABLED_EVENTS"`
	RetentionDays   int           `env:"AUTHARA_SECURITY_EVENT_RETENTION_DAYS,default=180"`
	CleanupInterval time.Duration `env:"AUTHARA_SECURITY_EVENT_CLEANUP_INTERVAL,default=24h"`

	EnabledEventSet map[domain.SecurityEventType]struct{}
}

func (*SecurityEvents) EventEnabled added in v0.22.0

func (s *SecurityEvents) EventEnabled(eventType domain.SecurityEventType) bool

type Service added in v0.21.0

type Service struct {
	*Config
	// contains filtered or unexported fields
}

func NewService added in v0.21.0

func NewService(ctx context.Context, cfg ServiceOptions) (*Service, error)

func (*Service) Clear added in v0.21.0

func (s *Service) Clear(ctx context.Context, key Key, actorID uuid.UUID, expectedRevision int64) (Description, error)

func (*Service) Current added in v0.21.0

func (s *Service) Current() ChallengePolicy

Current is retained for compatibility with the initial challenge-policy API. New consumers should use the service-specific CurrentChallenge method.

func (*Service) CurrentAdmin added in v0.21.0

func (s *Service) CurrentAdmin() AdminPolicy

func (*Service) CurrentAllowlist added in v0.21.0

func (s *Service) CurrentAllowlist() AllowlistPolicy

func (*Service) CurrentAuthentication added in v0.21.0

func (s *Service) CurrentAuthentication() AuthenticationPolicy

func (*Service) CurrentChallenge added in v0.21.0

func (s *Service) CurrentChallenge() ChallengePolicy

func (*Service) CurrentEmail added in v0.21.0

func (s *Service) CurrentEmail() EmailPolicy

func (*Service) CurrentOrganization added in v0.21.0

func (s *Service) CurrentOrganization() OrganizationPolicy

func (*Service) CurrentRateLimits added in v0.21.0

func (s *Service) CurrentRateLimits() RateLimitPolicy

func (*Service) CurrentSession added in v0.21.0

func (s *Service) CurrentSession() SessionPolicy

func (*Service) CurrentSessionCookies added in v0.21.0

func (s *Service) CurrentSessionCookies() SessionCookiePolicy

func (*Service) CurrentToken added in v0.21.0

func (s *Service) CurrentToken() TokenPolicy

func (*Service) CurrentUI added in v0.21.0

func (s *Service) CurrentUI() UIPolicy

func (*Service) CurrentWebhook added in v0.21.0

func (s *Service) CurrentWebhook() WebhookPolicy

func (*Service) Describe added in v0.21.0

func (s *Service) Describe(key Key) (Description, error)

func (*Service) List added in v0.21.0

func (s *Service) List() []Description

func (*Service) Reconcile added in v0.21.0

func (s *Service) Reconcile(ctx context.Context) error

func (*Service) ReconcilerDone added in v0.22.0

func (s *Service) ReconcilerDone() <-chan struct{}

func (*Service) Set added in v0.21.0

func (s *Service) Set(ctx context.Context, key Key, rawValue string, actorID uuid.UUID, expectedRevision int64) (Description, error)

func (*Service) ShutdownReconciler added in v0.22.0

func (s *Service) ShutdownReconciler(ctx context.Context) error

func (*Service) StartReconciler added in v0.21.0

func (s *Service) StartReconciler(ctx context.Context)

func (*Service) Startup added in v0.21.0

func (s *Service) Startup() *Config

Startup returns the immutable environment configuration used to construct process-level dependencies. Dynamic consumers should use the typed policy readers exposed by Service instead.

type ServiceOptions added in v0.21.0

type ServiceOptions struct {
	Startup           *Config
	Store             RuntimeSettingsStore
	LookupEnvironment func(string) (string, bool)
	Environment       []EnvironmentVariable
	Logger            *slog.Logger
	ReconcileInterval time.Duration
	Metrics           RuntimeSettingsMetrics
}

type Session

type Session struct {
	SessionTTLDays                int           `env:"AUTHARA_SESSION_TTL_DAYS,default=60"`
	RefreshTokenTTLDays           int           `env:"AUTHARA_REFRESH_TOKEN_TTL_DAYS,default=14"`
	RefreshTokenRotationRaw       string        `env:"AUTHARA_REFRESH_TOKEN_ROTATION_INTERVAL,default=24h"`
	RecentAuthenticationEnabled   bool          `env:"AUTHARA_RECENT_AUTHENTICATION_ENABLED,default=true"`
	RecentAuthenticationWindowRaw string        `env:"AUTHARA_RECENT_AUTHENTICATION_WINDOW,default=10m"`
	CleanupInterval               time.Duration `env:"AUTHARA_SESSION_CLEANUP_INTERVAL,default=5m"`

	SessionTTL                 time.Duration
	RefreshTokenTTL            time.Duration
	RefreshTokenRotation       time.Duration
	RecentAuthenticationWindow time.Duration
}

type SessionCookiePolicy added in v0.21.0

type SessionCookiePolicy struct {
	AccessTokenTTL  time.Duration
	RefreshTokenTTL time.Duration
}

SessionCookiePolicy is an HTTP-consumer snapshot combining the two policy groups needed to write a consistent access/refresh cookie pair.

type SessionCookiePolicyReader added in v0.21.0

type SessionCookiePolicyReader interface {
	CurrentSessionCookies() SessionCookiePolicy
}

type SessionCookiePolicyReaderFunc added in v0.21.0

type SessionCookiePolicyReaderFunc func() SessionCookiePolicy

func (SessionCookiePolicyReaderFunc) CurrentSessionCookies added in v0.21.0

func (f SessionCookiePolicyReaderFunc) CurrentSessionCookies() SessionCookiePolicy

type SessionPolicy added in v0.21.0

type SessionPolicy struct {
	SessionTTL                  time.Duration
	RefreshTokenTTL             time.Duration
	RefreshTokenRotation        time.Duration
	RecentAuthenticationEnabled bool
	RecentAuthenticationWindow  time.Duration
}

type SessionPolicyReader added in v0.21.0

type SessionPolicyReader interface {
	CurrentSession() SessionPolicy
}

type SessionPolicyReaderFunc added in v0.21.0

type SessionPolicyReaderFunc func() SessionPolicy

func (SessionPolicyReaderFunc) CurrentSession added in v0.21.0

func (f SessionPolicyReaderFunc) CurrentSession() SessionPolicy

type Source added in v0.21.0

type Source string
const (
	SourceEnvironment Source = "environment"
	SourceOperator    Source = "operator"
	SourceDefault     Source = "default"
	SourceUnset       Source = "unset"
)

type StaticChallengePolicy added in v0.21.0

type StaticChallengePolicy struct {
	Policy ChallengePolicy
}

func (StaticChallengePolicy) CurrentChallenge added in v0.21.0

func (s StaticChallengePolicy) CurrentChallenge() ChallengePolicy

type Token

type Token struct {
	Issuer                string            `env:"AUTHARA_JWT_ISSUER,required"`
	ActiveKeyID           string            `env:"AUTHARA_JWT_ACTIVE_KEY_ID,required"`
	Keys                  map[string]string `env:"AUTHARA_JWT_KEYS,required"`
	AccessTokenTTLMinutes int               `env:"AUTHARA_ACCESS_TOKEN_TTL_MINUTES,default=10"`

	AccessTokenTTL time.Duration
	KeySet         *token.KeySet
}

type TokenPolicy added in v0.21.0

type TokenPolicy struct {
	AccessTokenTTL time.Duration
}

type TokenPolicyReader added in v0.21.0

type TokenPolicyReader interface {
	CurrentToken() TokenPolicy
}

type TokenPolicyReaderFunc added in v0.21.0

type TokenPolicyReaderFunc func() TokenPolicy

func (TokenPolicyReaderFunc) CurrentToken added in v0.21.0

func (f TokenPolicyReaderFunc) CurrentToken() TokenPolicy

type UI added in v0.10.0

type UI struct {
	AppName         string `env:"AUTHARA_APP_NAME,default=Authara"`
	DefaultReturnTo string `env:"AUTHARA_DEFAULT_RETURN_TO,default=/"`
}

type UIPolicy added in v0.21.0

type UIPolicy struct {
	AppName         string
	DefaultReturnTo string
}

type UIPolicyReader added in v0.21.0

type UIPolicyReader interface {
	CurrentUI() UIPolicy
}

type UIPolicyReaderFunc added in v0.21.0

type UIPolicyReaderFunc func() UIPolicy

func (UIPolicyReaderFunc) CurrentUI added in v0.21.0

func (f UIPolicyReaderFunc) CurrentUI() UIPolicy

type ValueType added in v0.21.0

type ValueType string
const (
	TypeBool     ValueType = "bool"
	TypeInt      ValueType = "int"
	TypeDuration ValueType = "duration"
	TypeString   ValueType = "string"
	TypeEnum     ValueType = "enum"
	TypeURL      ValueType = "url"
	TypeCSV      ValueType = "csv"
	TypeMap      ValueType = "map"
)

type Values

type Values struct {
	AppEnv               string `env:"APP_ENV,default=dev"`
	PublicURL            string `env:"PUBLIC_URL,required"`
	TrustProxyHeaders    bool   `env:"AUTHARA_TRUST_PROXY_HEADERS,default=false"`
	TrustedProxyCIDRsRaw string `env:"AUTHARA_TRUSTED_PROXY_CIDRS"`

	HttpAddr string
}

type Webhook added in v0.1.3

type Webhook struct {
	URLRaw               string        `env:"AUTHARA_WEBHOOK_URL"`
	Secret               string        `env:"AUTHARA_WEBHOOK_SECRET"`
	EnabledEvents        []string      `env:"AUTHARA_WEBHOOK_ENABLED_EVENTS"`
	Timeout              time.Duration `env:"AUTHARA_WEBHOOK_TIMEOUT,default=5s"`
	WorkerCount          int           `env:"AUTHARA_WEBHOOK_WORKER_COUNT,default=2"`
	MaxDeliveryAttempts  int           `env:"AUTHARA_WEBHOOK_MAX_DELIVERY_ATTEMPTS,default=3"`
	ProcessingStaleAfter time.Duration `env:"AUTHARA_WEBHOOK_PROCESSING_STALE_AFTER,default=2m"`
	StaleReaperInterval  time.Duration `env:"AUTHARA_WEBHOOK_STALE_REAPER_INTERVAL,default=1m"`
	DeliveredRetention   time.Duration `env:"AUTHARA_WEBHOOK_DELIVERED_RETENTION,default=24h"`
	FailedRetention      time.Duration `env:"AUTHARA_WEBHOOK_FAILED_RETENTION,default=720h"`
	CleanupInterval      time.Duration `env:"AUTHARA_WEBHOOK_CLEANUP_INTERVAL,default=1h"`
	MaintenanceBatchSize int           `env:"AUTHARA_WEBHOOK_MAINTENANCE_BATCH_SIZE,default=1000"`

	URL             string
	EnabledEventSet map[string]struct{}
}

func (*Webhook) Enabled added in v0.1.3

func (w *Webhook) Enabled() bool

func (*Webhook) EventEnabled added in v0.1.3

func (w *Webhook) EventEnabled(name string) bool

type WebhookPolicy added in v0.21.0

type WebhookPolicy struct {
	EnabledEvents        []string
	Timeout              time.Duration
	MaxDeliveryAttempts  int
	ProcessingStaleAfter time.Duration
	DeliveredRetention   time.Duration
	FailedRetention      time.Duration
	MaintenanceBatchSize int
}

type WebhookPolicyReader added in v0.21.0

type WebhookPolicyReader interface {
	CurrentWebhook() WebhookPolicy
}

type WebhookPolicyReaderFunc added in v0.21.0

type WebhookPolicyReaderFunc func() WebhookPolicy

func (WebhookPolicyReaderFunc) CurrentWebhook added in v0.21.0

func (f WebhookPolicyReaderFunc) CurrentWebhook() WebhookPolicy

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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