hCaptcha

hCaptcha CAPTCHA extension

The hCaptcha extension protects actions with hCaptcha, a third-party CAPTCHA service. The visitor ticks a checkbox, and may be asked to solve a visual puzzle.

When a visitor performs a protected action, their browser loads the hCaptcha script and talks to hCaptcha. Nothing is loaded while the visitor merely reads the comments.

How it works

  1. When a visitor submits a protected action, the comments widget loads the hCaptcha script and shows the challenge in a small dialog. Once the visitor passes it, the dialog closes.
  2. The resulting token is sent along with the action.
  3. Comentario has hCaptcha verify the token, and checks that it was obtained on one of the domain’s hosts.

Like reCAPTCHA v2, and unlike Turnstile and reCAPTCHA v3, hCaptcha doesn’t tell which action a token was obtained for, so Comentario can’t check it: a token solved for registering, say, is just as good for posting a comment. Every token can be used only once, so each action still costs a solved challenge.

If hCaptcha 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. Add a site in the hCaptcha dashboard.
  2. List the hostnames 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’s site key and your account’s secret key.
NOTE
hCaptcha’s test keys report a dummy hostname, which Comentario refuses. Use a real site key.

Configuration

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

  • Globally, in the secrets, as extensions.hcaptcha.key and extensions.hcaptcha.secret.
  • Per domain, in the extension configuration, which takes precedence over the global key:
siteKey=10000000-ffff-ffff-ffff-000000000001
secret=0x0000...

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 can be disabled for the whole instance with extensions.hcaptcha.disable in the secrets.

Content Security Policy

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

script-src https://hcaptcha.com https://*.hcaptcha.com;
frame-src https://hcaptcha.com https://*.hcaptcha.com;
style-src https://hcaptcha.com https://*.hcaptcha.com;
connect-src https://hcaptcha.com https://*.hcaptcha.com;

Privacy

hCaptcha sends data about the visitor and their browser to hCaptcha. Mention it in your site’s privacy policy when you enable the extension.

See also