registerpolicy

package
v1.15.21 Latest Latest
Warning

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

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

Documentation

Overview

Package registerpolicy enforces the administrator-configured account policies shared by every authentication and registration path.

Index

Constants

View Source
const (
	MethodEmail  = authmethod.Email
	MethodMobile = authmethod.Mobile
	MethodDevice = authmethod.Device
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Auths repository.AuthRepo
	Redis *redis.Client
	// Config snapshots the runtime-mutable policy settings per call.
	Config func() Snapshot
}

Deps declares the policy's collaborators; the identity facade provides them.

type ServicePolicy

type ServicePolicy struct {
	// contains filtered or unexported fields
}

ServicePolicy is the use-case policy port implementation.

func New

func New(deps Deps) ServicePolicy

func (ServicePolicy) EnsureMethodEnabled

func (p ServicePolicy) EnsureMethodEnabled(ctx context.Context, method string) error

EnsureMethodEnabled rejects direct calls to authentication methods disabled by the administrator. OAuth methods are loaded from the auth_method table.

func (ServicePolicy) EnsureRegistrationOpen

func (p ServicePolicy) EnsureRegistrationOpen(ctx context.Context, method string) error

EnsureRegistrationOpen applies policies shared by every new-account path.

func (ServicePolicy) TakeIPPermit

func (p ServicePolicy) TakeIPPermit(ctx context.Context, ip string) error

TakeIPPermit atomically reserves one registration from the configured IP quota. The duration is configured in minutes.

func (ServicePolicy) VerifyHuman

func (p ServicePolicy) VerifyHuman(ctx context.Context, token, ip string) error

VerifyHuman enforces the configured registration Turnstile challenge.

type Snapshot

type Snapshot struct {
	EmailEnabled  bool
	MobileEnabled bool
	DeviceEnabled bool

	StopRegister            bool
	RegisterVerify          bool
	TurnstileSecret         string
	EnableIpRegisterLimit   bool
	IpRegisterLimit         int64
	IpRegisterLimitDuration int64
}

Snapshot is the per-request view of the runtime-mutable policy settings.

Jump to

Keyboard shortcuts

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