recaptcha

package
v1.3.10 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// V2 recaptcha api v2
	V2 VERSION = iota
	// V3 recaptcha api v3, more details can be found here : https://developers.google.com/recaptcha/docs/v3
	V3
	// DefaultTreshold Default minimin score when using V3 api
	DefaultTreshold float32 = 0.5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ReCAPTCHA

type ReCAPTCHA struct {
	Secret        string
	ReCAPTCHALink string
	Version       VERSION
	Timeout       time.Duration
	// contains filtered or unexported fields
}

ReCAPTCHA recpatcha holder struct, make adding mocking code simpler

func NewReCAPTCHA

func NewReCAPTCHA(ReCAPTCHASecret string, version VERSION, timeout time.Duration) (ReCAPTCHA, error)

NewReCAPTCHA new ReCAPTCHA instance if version is set to V2 uses recatpcha v2 API, get your secret from https://www.google.com/recaptcha/admin

if version is set to V2 uses recatpcha v2 API, get your secret from https://g.co/recaptcha/v3

func (*ReCAPTCHA) Verify

func (r *ReCAPTCHA) Verify(challengeResponse string) error

Verify returns `nil` if no error and the client solved the challenge correctly

func (*ReCAPTCHA) VerifyWithOptions

func (r *ReCAPTCHA) VerifyWithOptions(challengeResponse string, options VerifyOption) error

VerifyWithOptions returns `nil` if no error and the client solved the challenge correctly and all options are natching `Threshold` and `Action` are ignored when using V2 version

type VERSION

type VERSION int8

VERSION the recaptcha api version

type VerifyOption

type VerifyOption struct {
	Threshold      float32 // ignored in v2 recaptcha
	Action         string  // ignored in v2 recaptcha
	Hostname       string
	ApkPackageName string
	ResponseTime   time.Duration
	RemoteIP       string
}

VerifyOption verification options expected for the challenge

Jump to

Keyboard shortcuts

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