Google reCAPTCHA v3

Google reCAPTCHA v3 CAPTCHA extension

The Google reCAPTCHA v3 extension protects actions with reCAPTCHA v3, Google’s invisible CAPTCHA. It never asks the visitor anything: instead, Google rates how likely the visitor is a human, with a score from 0 to 1.

When a visitor performs a protected action, their browser loads Google’s script and talks to Google. Nothing is loaded while the visitor merely reads the comments. Once loaded, the script shows a small reCAPTCHA badge in the corner of the page.

How it works

  1. When a visitor submits a protected action, the comments widget loads the reCAPTCHA script and obtains a token for the action, without any dialog.
  2. The token is sent along with the action.
  3. Comentario has Google verify the token, checks that it was obtained on one of the domain’s hosts and for the action being performed, and that its score reaches the configured minimum.

If Google can’t be reached, a comment without registration is still accepted, but held for moderation, so that an outage doesn’t silence your site. Logging in goes ahead without the challenge. Registering a commenter fails with a message to try again later.

Setup

  1. Register a site of type Score based (v3) in the reCAPTCHA admin console. reCAPTCHA v2 keys don’t work with this extension: use reCAPTCHA v2 for them.
  2. List the domains the comments are embedded on, i.e. the domain’s host and any other origin it allows. For the Administration UI, list Comentario’s own hostname.
  3. Copy the site key and the secret key.

Configuration

The site key and the secret can be provided in two ways:

  • Globally, in the secrets, as extensions.recaptcha3.key and extensions.recaptcha3.secret.
  • Per domain, in the extension configuration, which takes precedence over the global key.

Both values must be given together. If no global key is configured, the domain has to provide its own, otherwise the domain can’t be saved.

The extension configuration also accepts the minimum score:

siteKey=6Lc...
secret=6Lc...
minScore=0.5
KeyTypeDescriptionDefault
minScorenumberScore (0…1) a token must reach. A higher value refuses more bots, but also more humans0.5

The Administration UI always uses the default minimum score.

The extension can be disabled for the whole instance with extensions.recaptcha3.disable in the secrets.

Content Security Policy

If the embedding page has a Content Security Policy, allow reCAPTCHA’s script and frames:

script-src https://www.google.com/recaptcha/ https://www.gstatic.com/recaptcha/;
frame-src https://www.google.com/recaptcha/ https://recaptcha.google.com/recaptcha/;

Privacy

reCAPTCHA sends data about the visitor and their browser to Google, and is subject to Google’s Privacy Policy and Terms of Service. Mention it in your site’s privacy policy when you enable the extension.

See also