2017 © Pedro PelĂĄez
 

craft-plugin recaptcha-verify

Verifies Recaptcha with Google's API

image

radiergummi/recaptcha-verify

Verifies Recaptcha with Google's API

  • Wednesday, December 13, 2017
  • by Radiergummi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 24 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 140 % Grown

The README.md

Recaptcha Verify plugin for Craft CMS 3.x

Verifies Recaptcha with Google's API., (*1)

Latest Stable Version Latest Unstable Version License Total Downloads, (*2)

Requirements

This plugin requires Craft CMS 3.0.0-beta.23 or later., (*3)

Installation

To install the plugin, follow these instructions., (*4)

  1. Open your terminal and go to your Craft project:
 cd /path/to/project
  1. Then tell Composer to load the plugin:
 composer require radiergummi/recaptcha-verify
  1. In the Control Panel, go to Settings → Plugins and click the “Install” button for Recaptcha Verify.

Recaptcha Verify Overview

Recaptcha Verify validates Recaptcha tokens against Google's library. This is most possibly the smallest plugin I've ever written for any CMS (ignoring my debugTheme plugin for WordPress, which has an astonishing 3 lines to offer)., (*5)

Using Recaptcha Verify

Recaptcha Verify provides a new POST action to Craft: recaptcha-verify/verify, that enables you to verify your responses. It also provides listeners for the contact form plugin, so you can verify your submissions. Details below., (*6)

The action expects the body content to contain CRAFT_CSRF_TOKEN and token, where token is the Recaptcha token received from Google. To set up the client side verification process, take a peek at the Google documentation., (*7)

The response will be a 400 error if - you don't have a secret configured in the settings - there is no token in the POST body, (*8)

The response will be a 200 success if - the token could be validated ({status: 'success'} as response body) - the token could not be validated ({status: 'failed'} as response body), (*9)

It might sound strange to not throw an error for a validation issue, but it's actually just the result of the action asked for. How you handle that error on the client side is up to you. If there is substantial interest in that being changed to throw an error too, I'll update the plugin., (*10)

Configuring Recaptcha Verify

There are two settings fields: Your Recaptcha API site key and secret. You can acquire them here: https://www.google.com/recaptcha/admin, (*11)

Fill the values as they are presented on the Google instructions page. You can also use a (multi-environment aware) configuration file named recaptcha-verify.php., (*12)

ContactForm integration

This is still a TODO scheduled for 0.3.0 :wink:
Currently I'm not sure on how to make this optional, if anyone would like to help out, I'm open for PRs or issues.
, (*13)

To validate the token within a form submission, include the field message[token] in your form submission. Recaptcha does currently not (and most likely never will) support browsers without JavaScript, so you'll need to submit it via JS anyway.
See the following example form for reference:, (*14)




< script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit" async defer>

Brought to you by Radiergummi, (*15)

The Versions

13/12 2017

dev-master

9999999-dev

Verifies Recaptcha with Google's API

  Sources   Download

MIT

The Requires

 

cms google recaptcha craftcms craft-plugin craft

13/12 2017

0.2.7

0.2.7.0

Verifies Recaptcha with Google's API

  Sources   Download

MIT

The Requires

 

cms google recaptcha craftcms craft-plugin craft

13/12 2017

0.2.6

0.2.6.0

Verifies Recaptcha with Google's API

  Sources   Download

MIT

The Requires

 

cms google recaptcha craftcms craft-plugin craft

13/12 2017

0.2.5

0.2.5.0

Verifies Recaptcha with Google's API

  Sources   Download

MIT

The Requires

 

cms google recaptcha craftcms craft-plugin craft

13/12 2017

0.2.4

0.2.4.0

Verifies Recaptcha with Google's API

  Sources   Download

MIT

The Requires

 

cms google recaptcha craftcms craft-plugin craft

13/12 2017

0.2.3

0.2.3.0

Verifies Recaptcha with Google's API

  Sources   Download

MIT

The Requires

 

cms google recaptcha craftcms craft-plugin craft

13/12 2017

0.2.1

0.2.1.0

Verifies Recaptcha with Google's API

  Sources   Download

MIT

The Requires

 

cms google recaptcha craftcms craft-plugin craft