Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Captcha ¶
type Captcha[P CaptchaProvider, S Storage] struct { // contains filtered or unexported fields }
Captcha verified captcha limit
func NewVerifiedCaptcha ¶
func NewVerifiedCaptcha[P CaptchaProvider, S Storage](p P, store S, opts ...Option) *Captcha[P, S]
NewVerifiedCaptcha new captcha instance.
func (*Captcha[P, S]) Generate ¶
func (v *Captcha[P, S]) Generate(ctx context.Context, kind string, opts ...GenerateOption) (id, question string, err error)
Generate generate id, question.
type CaptchaDriver ¶
type CaptchaDriver interface { Name() string GenerateQuestionAnswer() (*QuestionAnswer, error) }
CaptchaDriver the captcha driver
type CaptchaProvider ¶
type CaptchaProvider interface {
AcquireDriver(kind string) CaptchaDriver
}
CaptchaProvider the captcha provider
type GenerateOption ¶
type GenerateOption func(GenerateOptionSetter)
GenerateOption generate option
func WithGenerateKeyExpires ¶
func WithGenerateKeyExpires(t time.Duration) GenerateOption
WithGenerateKeyExpires redis存验证码key的过期时间
func WithGenerateMaxErrQuota ¶
func WithGenerateMaxErrQuota(quota int) GenerateOption
WithGenerateMaxErrQuota 设置最大错误验证次数 NOTE: 仅禁用一次性验证器时, 该功能有效
type GenerateOptionSetter ¶
type GenerateOptionSetter interface {
// contains filtered or unexported methods
}
GenerateOptionSetter generate option setter
type Option ¶
type Option func(OptionSetter)
Option 选项
func WithKeyPrefix ¶
WithKeyPrefix redis存验证码key的前缀, 默认 limit:captcha:
func WithMaxErrQuota ¶
SetMaxErrQuota 设置最大错误次数验证, 并禁用一次性验证 NOTE: 并设置最大错误次数验证, 将禁用一次性验证(默认验证器一次性有效)
type OptionSetter ¶
type OptionSetter interface {
// contains filtered or unexported methods
}
OptionSetter option setter
type QuestionAnswer ¶
QuestionAnswer question and answer for CaptchaDriver driver
type Reflux ¶
type Reflux[P RefluxProvider, S Storage] struct { // contains filtered or unexported fields }
Reflux verified reflux limiter
func NewVerifiedReflux ¶
func NewVerifiedReflux[P RefluxProvider, S Storage](p P, s S, opts ...Option) *Reflux[P, S]
NewVerifiedReflux new reflux instance.
type RefluxProvider ¶
RefluxProvider the reflux provider
type Storage ¶
type Storage interface { Store(context.Context, *StoreArgs) error Verify(context.Context, *VerifyArgs) bool }
Storage store engine
type StoreArgs ¶
type StoreArgs struct { DisableOneTime bool Key string KeyExpires time.Duration MaxErrQuota int Answer string }
StoreArgs store arguments
type UnsupportedVerifiedCaptchaDriver ¶
type UnsupportedVerifiedCaptchaDriver struct{}
func (UnsupportedVerifiedCaptchaDriver) GenerateQuestionAnswer ¶
func (x UnsupportedVerifiedCaptchaDriver) GenerateQuestionAnswer() (*QuestionAnswer, error)
func (UnsupportedVerifiedCaptchaDriver) Name ¶
func (x UnsupportedVerifiedCaptchaDriver) Name() string
type VerifyArgs ¶
VerifyArgs verify arguments