reCAPTCHA Application

Last modified by Vincent Massol on 2022/02/21 00:27

eyereCAPTCHA based implementation for the XWiki CAPTCHA Application
TypeXAR
CategoryOther
Developed by

Eduard Moraru

Active Installs12
Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Compatibility

10.8RC1+

Installable with the Extension Manager

Description

Extension to the CAPTCHA Application allowing the use of the Google reCAPTCHA online service.

Currently, the extension uses reCAPTCHA v2 (i.e. the version with the "I am not a robot" checkbox):

reCAPTCHA_v2.gif

After installing the extension, go to the Administration >> CAPTCHA in order to activate and configure it:

captcha-recaptcha.png

By default, the reCAPTCHA extension comes configured with Google testing site API keys, so the sample and your CAPTCHAs might look like this:

captcha-recaptcha-testing-keys.png

Configuration

You need to configure reCAPTCHA to use your own API keys. To do that, head over to https://www.google.com/recaptcha/admin, log in in with your Google account and register a new site and making sure you choose the correct reCAPTCHA v2 reCAPTCHA type.

Once the new site is created, click on it and go to the section "Adding reCAPTCHA to your site >> Keys". There you will find the 2 important configuration parameters that you have to copy over to the XWiki reCAPTCHA extension: Site key and Secret key.

Once you save your changes, you should see the Sample presenting a proper reCAPTCHA, without any red errors on top of it.

Enjoy your robot-free wiki!

Using different API keys

Google reCAPTCHA seems to encourage your to create a CAPTCHA for each section of your website where you want to use CAPTCHAs. That might be a bit much and it would be recommended to use the same keys everywhere on your site. However, if you do want to use different API keys, you can easily specify them as parameters when you display and validate your CAPTCHA in your form:

## When displaying the form:
$services.captcha.recaptcha.display({'siteKey' : 'YourOtherSiteKey', 'secretKey' : 'YourOtherSecretKey'})

## When validating the form:
#if (!$services.captcha.recaptcha.isValid({'siteKey' : 'YourOtherSiteKey', 'secretKey' : 'YourOtherSecretKey'}))
 {{error}}Bad robot!{{/error}}
#end

Note that you could also use the default CAPTCHA implementation (i.e. $services.captcha.default.display({'siteKey' : ...) to try to make your code more resilient over time so that you can still change the CAPTCHA you want to use from Administration without touching the form's code. However, it is not guaranteed that it will work all the time. For example, one CAPTCHA implementation could use a parameter with the same name so it could cause it to fail with the reCAPTCHA-related value that you provide. This is why, it is recommended to address the particular implementation you are using when making custom CAPTCHA forms.

Other customizable parameters

As you can see from the Administration section, you could create custom CAPTCHA forms by configuring the following parameters (ignoring the wiki-level configured values, specified in Administration):

Parameter NameDefault ValueAccepted Values
themelightlight, dark
sizenormalnormal, compact
tabIndex0integer value

See reCAPTCHA's Developer documentation for some more information.

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki

Dependencies

Dependencies for this extension (org.xwiki.contrib:captcha-recaptcha-ui 1.0):

  • org.xwiki.contrib:captcha-recaptcha-api 1.0
Tags:
    

Get Connected