captcha

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyCaptcha

func VerifyCaptcha(ctx context.Context, redisClient *redis.Client, captchaType string, turnstileSecret string, input VerifyInput) error

Types

type CaptchaType

type CaptchaType string
const (
	CaptchaTypeLocal     CaptchaType = "local"
	CaptchaTypeTurnstile CaptchaType = "turnstile"
	CaptchaTypeSlider    CaptchaType = "slider"
)

type Config

type Config struct {
	Type            CaptchaType
	RedisClient     *redis.Client
	TurnstileSecret string
}

type Service

type Service interface {
	Generate(ctx context.Context) (id string, image string, err error)
	Verify(ctx context.Context, token string, code string, ip string) (bool, error)
	GetType() CaptchaType
}

func NewService

func NewService(config Config) Service

type SliderService

type SliderService interface {
	Service
	GenerateSlider(ctx context.Context) (id string, bgImage string, blockImage string, err error)
	VerifySlider(ctx context.Context, id string, x, y int, trail string) (token string, err error)
	VerifySliderToken(ctx context.Context, token string) (bool, error)
}

func NewSliderService

func NewSliderService(redisClient *redis.Client) SliderService

type TrailPoint

type TrailPoint struct {
	X int   `json:"x"`
	Y int   `json:"y"`
	T int64 `json:"t"`
}

type VerifyInput

type VerifyInput struct {
	CaptchaID   string
	CaptchaCode string
	CfToken     string
	SliderToken string
	IP          string
}

Jump to

Keyboard shortcuts

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