Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// Client the HTTP client to make requests. The default is http.DefaultClient.
Client *http.Client
// Secret is the secret key to check user captcha codes. This field is required.
Secret string
VerifyURL
}
Options contains options for both recaptcha.RecaptchaV2 and recaptcha.RecaptchaV3 middleware.
type RecaptchaV2 ¶
type RecaptchaV2 interface {
// Verify verifies the given token. An optional remote IP of the user may be
// passed as extra security criteria.
Verify(token string, remoteIP ...string) (*ResponseV2, error)
}
RecaptchaV2 is a reCAPTCHA V2 verify interface.
type RecaptchaV3 ¶
type RecaptchaV3 interface {
// Verify verifies the given token. An optional remote IP of the user may be
// passed as extra security criteria.
Verify(token string, remoteIP ...string) (*ResponseV3, error)
}
RecaptchaV3 is a reCAPTCHA V3 verify interface.
type ResponseV2 ¶
type ResponseV2 struct {
// Success indicates whether the passcode valid, and does it meet security
// criteria you specified.
Success bool `json:"success"`
// ChallengeTS is the timestamp of the challenge load (ISO format
// yyyy-MM-dd'T'HH:mm:ssZZ).
ChallengeTS time.Time `json:"challenge_ts"`
// Hostname is the hostname of the site where the challenge was solved.
Hostname string `json:"hostname"`
// ErrorCodes contains the error codes when verify failed.
ErrorCodes []string `json:"error-codes"`
}
ResponseV2 is the response struct which Google send back to the client.
type ResponseV3 ¶
type ResponseV3 struct {
// Success indicates whether the passcode valid, and does it meet security
// criteria you specified.
Success bool `json:"success"`
// ChallengeTS is the timestamp of the challenge load (ISO format
// yyyy-MM-dd'T'HH:mm:ssZZ).
ChallengeTS time.Time `json:"challenge_ts"`
// Hostname is the hostname of the site where the challenge was solved.
Hostname string `json:"hostname"`
// ErrorCodes contains the error codes when verify failed.
ErrorCodes []string `json:"error-codes"`
// Score indicates the score of the request (0.0 - 1.0).
Score float64 `json:"score"`
// Action is the action name of the request.
Action string `json:"action"`
}
ResponseV3 is the response struct which Google send back to the client.
type VerifyURL ¶
type VerifyURL string
VerifyURL is the API URL to verify user input.
const ( // VerifyURLGoogle is the default API URL to verify reCAPTCHA requests. VerifyURLGoogle VerifyURL = "https://www.google.com/recaptcha/api/siteverify" // VerifyURLGlobal is API URL for the people who can't connect to the Google's server. VerifyURLGlobal VerifyURL = "https://www.recaptcha.net/recaptcha/api/siteverify" )
Click to show internal directories.
Click to hide internal directories.