captcha

package
v0.0.0-...-b34ddb9 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RecaptchaURL       = `https://www.google.com/recaptcha/api/siteverify`
	GRecaptchaResponse = `g-recaptcha-response`
	CaptchaHandle      = `handle`

	MaxCaptchaHandleLength = 80
)

Variables

View Source
var (
	ErrCaptchaHandleNotFound = &CaptchaErr{
		error:          errors.New("captcha handle not found"),
		SetCaptchaPage: func(p *page.Captcha) { p.CaptchaErr.IsNotFound = true },
	}
	ErrCaptchaVerifyFailed = &CaptchaErr{
		error:          errors.New("captcha verfication failed"),
		SetCaptchaPage: func(p *page.Captcha) { p.CaptchaErr.IsVerifyFailed = true },
	}
)

Functions

func Install

func Install(cfg *Config, r *mux.Router) error

Types

type CaptchaEntry

type CaptchaEntry struct {
	Handle string `json:"h"`
	Verify string `json:"v"`
}

type CaptchaErr

type CaptchaErr struct {
	SetCaptchaPage func(p *page.Captcha)
	// contains filtered or unexported fields
}

type Config

type Config struct {
	Enabled      bool
	InsertSecret string
	ExpireSecs   int
	Recaptcha    RecaptchaConfig
	Redis        RedisConfig
}

type Handler

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

type RecaptchaConfig

type RecaptchaConfig struct {
	SiteKey string
	Secret  string
}

type RedisConfig

type RedisConfig struct {
	Network  string
	Addr     string
	Password string
	DB       int
}

See https://godoc.org/github.com/go-redis/redis#Options

Jump to

Keyboard shortcuts

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