Documentation
¶
Overview ¶
Package verifycode implements the verification-code subdomain of the identity module: issuing and pre-checking the email and SMS codes that gate registration and account mutations. Only the module facade may reach it.
Index ¶
- Constants
- type Deps
- type Service
- func (s *Service) CheckVerificationCode(ctx context.Context, req *dto.CheckVerificationCodeRequest) (*dto.CheckVerificationCodeResponse, error)
- func (s *Service) SendEmailCode(ctx context.Context, req *dto.SendCodeRequest) (*dto.SendCodeResponse, error)
- func (s *Service) SendSmsCode(ctx context.Context, req *dto.SendSmsCodeRequest) (*dto.SendCodeResponse, error)
- type Snapshot
- type VerificationIdentityStore
- type VerificationTaskQueue
Constants ¶
const (
CodesPerIPPerHour = 20
)
Every code costs a delivery, and an SMS costs money. The per-address quotas alone do not bound a client that rotates addresses, so each client address also gets CodesPerIPPerHour codes an hour, whatever the addresses: enough for a person retrying a form or binding several addresses, far too few for a bombing or pumping script. An unknown address shares one quota.
const IntervalTime = 60
IntervalTime is the default number of seconds between two codes sent to one address.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Deps ¶
type Deps struct {
Store VerificationIdentityStore
Redis *redis.Client
Queue VerificationTaskQueue
Policy registerpolicy.Policy
// Config snapshots the runtime-mutable settings per request.
Config func() Snapshot
}
Deps declares the subdomain's dependencies; the identity facade forwards them from the composition root and supplies the account policy from the authentication subdomain.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the verification-code subdomain entry point used by the identity facade.
func NewService ¶
NewService builds the subdomain over the dependencies the facade forwards.
func (*Service) CheckVerificationCode ¶
func (s *Service) CheckVerificationCode(ctx context.Context, req *dto.CheckVerificationCodeRequest) (*dto.CheckVerificationCodeResponse, error)
CheckVerificationCode pre-checks a code without consuming it, for the UI. The phone number is normalized the way SendSmsCode stored it, so a number written with separators still matches its code.
func (*Service) SendEmailCode ¶
func (s *Service) SendEmailCode(ctx context.Context, req *dto.SendCodeRequest) (*dto.SendCodeResponse, error)
SendEmailCode sends a verification code to an email address: a register code to an address no account has, a security code to one an account has.
func (*Service) SendSmsCode ¶
func (s *Service) SendSmsCode(ctx context.Context, req *dto.SendSmsCodeRequest) (*dto.SendCodeResponse, error)
SendSmsCode sends a verification code to a phone number: a register code to a number no account has, a security code to one an account has. The code is stored under the number's E.164 form, the one every checker uses.
type Snapshot ¶
type Snapshot struct {
DomainSuffixList string
EnableDomainSuffix bool
VerifyCodeInterval int64
VerifyCodeLimit int64
VerifyCodeExpire int64
// MobileWhitelist lists the area codes SMS codes may be sent to when
// MobileWhitelistEnabled is set.
MobileWhitelistEnabled bool
MobileWhitelist []string
SiteLogo string
SiteName string
}
Snapshot is the per-request view of the runtime-mutable settings the verification-code flows consume.
type VerificationIdentityStore ¶
type VerificationIdentityStore interface {
UserAuth() repository.UserAuthRepo
}
VerificationIdentityStore is the persistence surface the code flows use to tell registration from security codes.