go-recaptcha: github.com/tekkamanendless/go-recaptcha Index | Files | Directories

package recaptcha

import "github.com/tekkamanendless/go-recaptcha"

Package recaptcha handles reCAPTCHA (http://www.google.com/recaptcha) form submissions

This package is designed to be called from within an HTTP server or web framework which offers reCAPTCHA form inputs and requires them to be evaluated for correctness


Package Files



const DefaultVerifyEndpoint = "https://www.google.com/recaptcha/api/siteverify"

DefaultVerifyEndpoint is the default production endpoint for verifying a token.

type Recaptcha Uses

type Recaptcha struct {
    VerifyEndpoint string // This is the endpoint; if empty, it will default to the production endpoint.
    PrivateKey     string // This is your site's private key.
    // contains filtered or unexported fields

Recaptcha contains the configuration and functions necessary to perform reCAPTCHA validations.

func New Uses

func New(privateKey string) *Recaptcha

New creates a new Recaptcha instance that can verify reCAPTCHA tokens.

func (*Recaptcha) Verify Uses

func (r *Recaptcha) Verify(response string) (bool, error)

Verify a response token.

func (*Recaptcha) VerifyRemoteIP Uses

func (r *Recaptcha) VerifyRemoteIP(remoteIP, response string) (bool, error)

VerifyRemoteIP verify a response token along with the IP address.

type RecaptchaResponse Uses

type RecaptchaResponse struct {
    Success     bool      `json:"success"`      // Whether this request was a valid reCAPTCHA token for your site.
    Score       float64   `json:"score"`        // (v3 only) The score for this request (0.0 - 1.0).
    Action      string    `json:"action"`       // (v3 only) The action name for this request (important to verify).
    ChallengeTS time.Time `json:"challenge_ts"` // Timestamp of the challenge load (ISO format yyyy-MM-dd'T'HH:mm:ssZZ).
    Hostname    string    `json:"hostname"`     // The hostname of the site where the reCAPTCHA was solved.
    ErrorCodes  []string  `json:"error-codes"`  // (Optional)

RecaptchaResponse is the response that we get back from the "siteverify" endpoint.



Package recaptcha imports 6 packages (graph) and is imported by 1 packages. Updated 2020-01-24. Refresh now. Tools for package owners. This is a quick bug-fix fork (has fewer than three commits, and only during the week it was created).