All Projects → ezzarghili → Recaptcha Go

ezzarghili / Recaptcha Go

Licence: mit
Validate Google reCAPTCHA v2 & v3 form submission package in golang

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Labels

Projects that are alternatives of or similar to Recaptcha Go

Nocaptcha
🛂 Helper for Google's new noCAPTCHA (reCAPTCHA v2 & v3)
Stars: ✭ 313 (+538.78%)
Mutual labels:  recaptcha
Vue Recaptcha
Google ReCAPTCHA component for Vue.js
Stars: ✭ 659 (+1244.9%)
Mutual labels:  recaptcha
Anticaptchaff
Firefox Extension to automatically solve and bypass reCaptcha
Stars: ✭ 20 (-59.18%)
Mutual labels:  recaptcha
Buster
Captcha solver extension for humans
Stars: ✭ 4,244 (+8561.22%)
Mutual labels:  recaptcha
Recaptcha
reCAPTCHA = REcognize CAPTCHA: A Burp Suite Extender that recognize CAPTCHA and use for intruder payload 自动识别图形验证码并用于burp intruder爆破模块的插件
Stars: ✭ 596 (+1116.33%)
Mutual labels:  recaptcha
Nonocaptcha
An asynchronized Python library to automate solving ReCAPTCHA v2 using audio
Stars: ✭ 744 (+1418.37%)
Mutual labels:  recaptcha
Laravel Recaptcha
Google ReCaptcha package for Laravel
Stars: ✭ 273 (+457.14%)
Mutual labels:  recaptcha
Drf Recaptcha
Django REST framework reCAPTCHA
Stars: ✭ 47 (-4.08%)
Mutual labels:  recaptcha
Rucaptcha
Captcha gem for Rails Application. No dependencies. No ImageMagick, No RMagick.
Stars: ✭ 607 (+1138.78%)
Mutual labels:  recaptcha
Recaptcha Rs
Verify recaptcha responses
Stars: ✭ 10 (-79.59%)
Mutual labels:  recaptcha
Vue Crud X
Vue+Express Cookbook & CRUD Component (with Vite and Web Components)
Stars: ✭ 393 (+702.04%)
Mutual labels:  recaptcha
React Recaptcha
A react.js reCAPTCHA for Google
Stars: ✭ 582 (+1087.76%)
Mutual labels:  recaptcha
Short
URL shortening service written in Go and React
Stars: ✭ 777 (+1485.71%)
Mutual labels:  recaptcha
Reaptcha
Google reCAPTCHA v2 for React
Stars: ✭ 329 (+571.43%)
Mutual labels:  recaptcha
Puppeteer Sharp Extra
Plugin framework for PuppeteerSharp
Stars: ✭ 39 (-20.41%)
Mutual labels:  recaptcha
Recaptcha
PHP client library for reCAPTCHA, a free service to protect your website from spam and abuse.
Stars: ✭ 3,149 (+6326.53%)
Mutual labels:  recaptcha
Django Recaptcha
Django reCAPTCHA form field/widget integration app.
Stars: ✭ 742 (+1414.29%)
Mutual labels:  recaptcha
Beelabrecaptcha2bundle
💻 Symfony bundle for Google Recaptcha2
Stars: ✭ 47 (-4.08%)
Mutual labels:  recaptcha
Captchavel
Integrate reCAPTCHA into your Laravel app better than the Big G itself!
Stars: ✭ 40 (-18.37%)
Mutual labels:  recaptcha
Passcore
A self-service password management tool for Active Directory
Stars: ✭ 787 (+1506.12%)
Mutual labels:  recaptcha

recaptcha-go

Build Status

Google reCAPTCHA v2 & v3 form submission verification in golang.

Usage

The API has changed form last version hence the new major version change.
Old API is still available using the package gopkg.in/ezzarghili/recaptcha-go.v2 although it does not provide all options available in this version.
As always install the package in your environment by using a stable API version, see latest version in releases page.

go get -u gopkg.in/ezzarghili/recaptcha-go.v4 

recaptcha v2 API

import "gopkg.in/ezzarghili/recaptcha-go.v4"
func main(){
    captcha, _ := recaptcha.NewReCAPTCHA(recaptchaSecret, recaptcha.V2, 10 * time.Second) // for v2 API get your secret from https://www.google.com/recaptcha/admin
}

Now everytime you need to verify a V2 API client with no special options request use.

err := captcha.Verify(recaptchaResponse)
if err != nil {
    // do something with err (log?)
    // Example check error codes array if they exist: (err.(*recaptcha.Error)).ErrorCodes
}
// proceed

For specific options use the VerifyWithOptions method
Available options for the v2 api are:

  Hostname       string
  ApkPackageName string
  ResponseTime   time.Duration
  RemoteIP       string

Other v3 options are ignored and method will return nil when succeeded.

err := captcha.VerifyWithOptions(recaptchaResponse, VerifyOption{RemoteIP: "123.123.123.123"})
if err != nil {
    // do something with err (log?)
    // Example check error codes array if they exist: (err.(*recaptcha.Error)).ErrorCodes
}
// proceed

recaptcha v3 API

import "gopkg.in/ezzarghili/recaptcha-go.v4"
func main(){
    captcha, _ := recaptcha.NewReCAPTCHA(recaptchaSecret, recaptcha.V3, 10 * time.Second) // for v3 API use https://g.co/recaptcha/v3 (apperently the same admin UI at the time of writing)
}

Now everytime you need to verify a V3 API client with no special options request use.

err := captcha.Verify(recaptchaResponse)
if err != nil {
    // do something with err (log?)
}
// proceed

Note that as recaptcha v3 use score for challenge validation, if no threshold option is set the default value is 0.5

For specific options use the VerifyWithOptions method.
Available options for the v3 api are:

   Threshold      float32
   Action         string
   Hostname       string
   ApkPackageName string
   ResponseTime   time.Duration
   RemoteIP       string
err := captcha.VerifyWithOptions(recaptchaResponse, VerifyOption{Action: "hompage", Threshold: 0.8})
if err != nil {
    // do something with err (log?)
}
// proceed

While recaptchaResponse is the form value with name g-recaptcha-response sent back by recaptcha server and set for you in the form when a user answers the challenge.

Both recaptcha.Verify and recaptcha.VerifyWithOptions return a error or nil if successful.

Use the error to check for issues with the secret, connection with the server, options mismatches and incorrect solution.

This version made timeout explcit to make sure users have the possiblity to set the underling http client timeout suitable for their implemetation.

Run Tests

Use the standard go means of running test. You can also check examples of usage in the tests.

go test

Issues with this library

If you have some problems with using this library, bug reports or enhancement please open an issue in the issues tracker.

License

Let's go with something permitive should we?

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].