Documentation
¶
Overview ¶
Package registerpolicy enforces the administrator-configured account policies shared by every authentication and registration path.
Index ¶
- Constants
- type Deps
- type ServicePolicy
- func (p ServicePolicy) EnsureMethodEnabled(ctx context.Context, method string) error
- func (p ServicePolicy) EnsureRegistrationOpen(ctx context.Context, method string) error
- func (p ServicePolicy) TakeIPPermit(ctx context.Context, ip string) error
- func (p ServicePolicy) VerifyHuman(ctx context.Context, token, ip string) error
- type Snapshot
Constants ¶
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.