config

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package config reads the configuration from environment variables. Invalid or contradictory settings are errors, so a misconfigured function fails at startup instead of misbehaving on a user's sign-up.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	LogLevel slog.Level

	PreSignUp         PreSignUp
	PostConfirmation  PostConfirmation
	PreAuthentication PreAuthentication
	EmailVerification EmailVerification
	SendGrid          SendGrid
}

Config is the function's configuration.

func FromEnv

func FromEnv() (*Config, error)

FromEnv reads the configuration from the process environment.

func Load

func Load(lookup func(string) (string, bool)) (*Config, error)

Load reads the configuration with lookup, which has the signature of os.LookupEnv. All problems are reported together.

type EmailVerification

type EmailVerification struct {
	Enabled bool
	// Triggers are the PreSignUp trigger sources to verify addresses for.
	Triggers []string
	// Allowlist holds domains that are treated as valid without calling
	// SendGrid.
	Allowlist []string
}

EmailVerification configures email verification for the PreSignUp hook.

type PasswordRotation added in v1.1.0

type PasswordRotation struct {
	Enabled bool
	// RotateBefore is the cutoff: a password the hooks haven't replaced
	// since this time is replaced at the user's next sign-in.
	RotateBefore time.Time
	// Table is the DynamoDB table that records each replacement.
	Table string
}

PasswordRotation configures the PreAuthentication hook's password rotation. Its settings are only required when it is enabled.

type PostConfirmation

type PostConfirmation struct {
	Enabled bool
	// PolicyPath is optional; without a policy every native user's password
	// is replaced.
	PolicyPath string
	// RotationTable is optional. When set, each replacement is recorded in
	// the table of the PreAuthentication hook's password rotation.
	RotationTable string
}

PostConfirmation configures the PostConfirmation hook.

type PreAuthentication added in v1.1.0

type PreAuthentication struct {
	Enabled bool
	// PolicyPath is optional.
	PolicyPath string
	// PasswordRotation is off by default.
	PasswordRotation PasswordRotation
}

PreAuthentication configures the PreAuthentication hook.

type PreSignUp

type PreSignUp struct {
	Enabled    bool
	PolicyPath string
}

PreSignUp configures the PreSignUp hook.

type SendGrid

type SendGrid struct {
	APIHost            string
	VerificationAPIKey string
}

SendGrid holds the SendGrid API settings.

Jump to

Keyboard shortcuts

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