Documentation
¶
Overview ¶
Package recaptcha implements server side validation of reCAPTCHA V3 responses.
See the below linked documentation for more information: https://developers.google.com/recaptcha/docs/v3 https://developers.google.com/recaptcha/docs/verify
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrCheck indicates that the reCAPTCHA response failed a check. ErrCheck = errors.New("reCAPTCHA check failed") // ErrInvalidVerifyInputs indicates that the reCAPTCHA V3 verify inputs are invalid. ErrInvalidVerifyInputs = errors.New("reCAPTCHA V3 verify inputs are invalid") )
Functions ¶
This section is empty.
Types ¶
type V3Response ¶
type V3Response struct {
APKPackageName string `json:"apk_package_name"`
Action string `json:"action"`
ChallengeTS time.Time `json:"challenge_ts"`
ErrorCodes []string `json:"error-codes"`
Hostname string `json:"hostname"`
Score float64 `json:"score"`
Success bool `json:"success"`
}
V3Response is the response from Google's reCAPTCHA V3 API.
func (V3Response) Check ¶
func (resp V3Response) Check(options V3ResponseCheckOptions) error
Check confirms the reCAPATCHA V3 response is valid and meets the given requirements.
type V3ResponseCheckOptions ¶
type V3ResponseCheckOptions struct {
// APKPackageName confirms the response's APK package name is in the given slice.
APKPackageName []string
// Action confirms the response's action is in the given slice.
Action []string
// Hostname confirms the response's hostname is in the given slice.
Hostname []string
// Score confirms the response's score is at least this value.
Score float64
}
V3ResponseCheckOptions are the options for checking a reCAPTCHA V3 response.
type VerifierV3 ¶
type VerifierV3 interface {
Verify(ctx context.Context, response string, remoteIP string) (V3Response, error)
}
VerifierV3 is the interface for verifying reCAPTCHA V3 responses.
func NewTestVerifierV3 ¶
func NewTestVerifierV3(response V3Response, err error) VerifierV3
NewTestVerifierV3 creates a new reCAPTCHA V3 verifier that returns the given response and error. The intended purpose is for testing.
func NewVerifierV3 ¶
func NewVerifierV3(secret string, options VerifierV3Options) VerifierV3
NewVerifierV3 creates a new reCAPTCHA V3 verifier.
type VerifierV3Options ¶
VerifierV3Options are the options for creating a new reCAPTCHA V3 verifier. All fields can safely be left blank.