The sign-in experience
CAPTCHA
On this page
Introduction
Some sign-in attempts come from scripts working through lists of passwords, not from people. A CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) is a challenge meant to tell a person from a script.
Signari's CAPTCHA is off by default, and adaptive when on. A person signing in normally never sees a challenge. A script sees one after a handful of failed attempts.
You turn it on with the SIGNARI_CAPTCHA_ environment variables on this page.
Every environment variable lists them all.
Turning it on
These settings turn on adaptive challenges from a hosted provider:
ShellSIGNARI_CAPTCHA_MODE=adaptive # off (default) | adaptive | alwaysSIGNARI_CAPTCHA_PROVIDER=turnstile # turnstile | hcaptcha | recaptcha | siteverifySIGNARI_CAPTCHA_SITE_KEY=...SIGNARI_CAPTCHA_SECRET=...SIGNARI_CAPTCHA_AFTER_FAILURES=3 # adaptive threshold, per source addressSIGNARI_CAPTCHA_FAIL_CLOSED=1 # optional; see below
In this example, a challenge appears after three failures from one address.
SIGNARI_CAPTCHA_FAIL_CLOSED is explained under
Fail open, by default.
A service you run yourself
siteverify is for a challenge service of your own. Then sign-in does not
depend on a third party, or send it the addresses of your people.
Your service has to speak the same shape as the others. It receives a POST of
secret, response and remoteip. It answers with JSON carrying a success
boolean and optionally error-codes. Point Signari at it with four more
settings:
ShellSIGNARI_CAPTCHA_PROVIDER=siteverifySIGNARI_CAPTCHA_VERIFY_URL=https://captcha.example.com/siteverifySIGNARI_CAPTCHA_WIDGET_URL=https://captcha.example.com/widget.jsSIGNARI_CAPTCHA_WIDGET_CLASS=my-captchaSIGNARI_CAPTCHA_RESPONSE_FIELD=my-captcha-response
All four are required, and both addresses must be https, since the verify address receives the secret. Setting them with any other provider stops Signari from starting, instead of being ignored.
The page renders <div class="my-captcha" data-sitekey="…"> and loads the
script. Only the script's origin joins the Content Security Policy (CSP), the
browser rule that says where a page may load scripts from. A widget that calls
anywhere else needs a theme with that written in.
The verify address goes through the outbound guard. So a service on a private
address has to be named in SIGNARI_OUTBOUND_ALLOW_PRIVATE.
Why off by default
A CAPTCHA costs every person who meets it time and effort, and automated solvers often pass them more reliably than people do. It is hardest on someone using a screen reader, an old browser, or a connection that looks unusual.
For these reasons, turning it on is left to the administrator.
Adaptive mode
A person signing in normally never sees a challenge. A script working through a password list sees one after a handful of attempts from the same address.
Failures are counted per source address, in memory, over a fifteen-minute window. A correct password clears that address. Many people in an office can share one address, through network address translation (NAT). The next person behind it should not inherit a challenge from a colleague who mistyped.
Failures are counted for every rejected sign-in, including ones where no such account exists. Counting only real accounts would make the appearance of a challenge an "oracle": a signal for which usernames are worth guessing.
What adaptive does not do
It does not stop a distributed attack. An attacker with a pool of addresses gets a fresh allowance from each.
The distributed case is limited by the per-account throttle, and by the global rate limit in front of Argon2, the function that checks passwords. Neither of them depends on the CAPTCHA.
Checked before the password
The challenge is verified before the credential lookup. So Signari spends an Argon2 evaluation only after a challenge has been solved.
A failed challenge also counts as a sign-in failure. Otherwise an attacker could hold an address's counter still by submitting blank challenges, and adaptive mode would never escalate.
Fail open, by default
When the provider cannot be reached, the sign-in proceeds and the failure is
logged. SIGNARI_CAPTCHA_FAIL_CLOSED=1 reverses that.
The challenge is checked in addition to the password, not instead of it. Failing open gives you the same protection as having no CAPTCHA. Failing closed means that while the provider is down, no one can sign in. The choice is yours.
The Content Security Policy
A challenge widget is third-party script running on the sign-in page, where an injected script would do the most harm. So the Content-Security-Policy is widened only when a challenge is configured, and only to that provider's own origins:
Textoff: script-src 'self'turnstile: script-src 'self' https://challenges.cloudflare.com
A deployment that does not turn on a CAPTCHA keeps the stricter policy.
Misconfiguration refuses to start
Signari refuses to start when these settings are wrong. Here are two mistakes, each with the message it gives:
TextSIGNARI_CAPTCHA_MODE=adaptative -> unknown captcha mode "adaptative": use off, adaptive or alwaysSIGNARI_CAPTCHA_MODE=adaptive, no keys -> SIGNARI_CAPTCHA_MODE is "adaptive" but SIGNARI_CAPTCHA_SITE_KEY or SIGNARI_CAPTCHA_SECRET is missing; a challenge with no keys renders an empty box and refuses every sign-in
Without this check, a typo in the mode would turn the CAPTCHA off while you believe it is on.
Verified
Each of these cases was checked:
| default (off) | page renders, no widget, script-src 'self' |
always | Turnstile widget with the site key, CSP widened to Cloudflare only |
| sign-in with no response | refused: "That challenge was not completed" |
| unsolved response | refused by the provider |
| provider unreachable | sign-in proceeds (fail open), logged |
FAIL_CLOSED=1, unreachable | refused |
| misspelled mode or provider | refuses to start |