signupprotection

package
v0.0.6-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package signupprotection applies bot verification and bounded throttles to public password signup.

Index

Constants

This section is empty.

Variables

View Source
var ErrClientIPUnavailable = errors.New("client IP unavailable")

ErrClientIPUnavailable means the configured source did not contain one valid address.

Functions

This section is empty.

Types

type ClientIPResolver

type ClientIPResolver interface {
	Resolve(*http.Request) (netip.Addr, error)
}

ClientIPResolver derives a client address from one configured source.

func NewCloudflareClientIPResolver

func NewCloudflareClientIPResolver() ClientIPResolver

NewCloudflareClientIPResolver trusts exactly one CF-Connecting-IP value. The origin must accept traffic exclusively from Cloudflare when this is used.

func NewDirectClientIPResolver

func NewDirectClientIPResolver() ClientIPResolver

NewDirectClientIPResolver reads the network peer and ignores proxy headers.

type PasswordSignupAttempt

type PasswordSignupAttempt struct {
	ClientIP       netip.Addr
	Email          string
	TurnstileToken string
}

PasswordSignupAttempt contains the untrusted inputs needed at the public password-signup request boundary.

type PasswordSignupProtection

type PasswordSignupProtection interface {
	Check(context.Context, PasswordSignupAttempt) *apperrors.ServiceError
}

PasswordSignupProtection decides whether password signup may continue.

func NewDisabledPasswordSignupProtection

func NewDisabledPasswordSignupProtection() PasswordSignupProtection

NewDisabledPasswordSignupProtection preserves self-hosted signup without cloud verification or throttling.

func NewPasswordSignupProtection

func NewPasswordSignupProtection(spec PasswordSignupProtectionSpec) (PasswordSignupProtection, error)

NewPasswordSignupProtection constructs cloud password-signup protection.

type PasswordSignupProtectionSpec

type PasswordSignupProtectionSpec struct {
	Verifier      turnstile.Verifier
	IPThrottle    ThrottleSpec
	EmailThrottle ThrottleSpec
}

PasswordSignupProtectionSpec contains the cloud verifier and bounded limits.

type ThrottleSpec

type ThrottleSpec struct {
	MaxTrackedKeys int
	MaxAttempts    int
	Window         time.Duration
	Now            func() time.Time
}

ThrottleSpec configures one bounded fixed-window attempt store.

Jump to

Keyboard shortcuts

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