Skip to content

Abuse protection: request limits, email check and Cloudflare Turnstile

Describes PhoenixKit 3.6.1.

The public sign-in and sign-up forms send email, and bots use them to send mail to made-up addresses. Every bounce counts against your site as a sender. The Abuse protection tab, new in PhoenixKit 3.6.0, shows the limits these forms work under and holds two defences: a check of the email address at sign-up and Cloudflare Turnstile.

Where to find it

Settings > Authorization, tab Abuse protection (/admin/settings/authorization?tab=protection). You need the Security settings permission (part of Settings). Each part of the tab has its own save button; Save Authorization Settings is not shown here.

The Abuse protection tab under Settings, Authorization: the Request limits table per page, email address, network and whole site, and the Email address check The Abuse protection tab under Settings, Authorization: the Request limits table per page, email address, network and whole site, and the Email address check

Settings → Authorization → Abuse protection.

Request limits

A read-only table of how many requests each public page accepts. A request is refused as soon as one of its limits is reached. The rows are Sign-in (failed attempts), Registration, Magic link, Password reset and Confirmation email resend; the columns are Per email address, Per network (IP), Whole site and Used now.

Used now shows how much of the whole-site limit is used (for example “12 of 300”), or Limit reached, and when it resets. A page with no whole-site limit says No limit. Refresh reads the counters again.

The whole-site limit is a circuit breaker: once it is reached, that page refuses everyone until it resets. Registration has one since 3.6.0, 300 sign-ups an hour unless a developer changes it. Raise it before a launch or anything else that sends many people to the sign-up page at once. Only the public sign-up forms count: sign-ups through Google or another sign-in provider, and users an admin adds, do not.

The limits are set in the application’s configuration, not here, and are counted separately on each server.

Email address check

Check the email address at sign-up is on by default. On the sign-up and registration link forms:

  • An address whose domain cannot receive mail is refused before anything is sent, with This email domain cannot receive mail. Please check the address.
  • A likely typo of a big provider (gmial.com) gets a Did you mean hint under the field. One click takes the suggestion; the person can also ignore it.
  • If the domain cannot be looked up in time, the address is accepted.

Save email address check stores the switch. If a developer has switched the check off in the app’s configuration, the tab says so and the switch has no effect.

The section also reminds you of a rule that needs no setting: an account that has not confirmed its address gets only the mail its holder asks for (the confirmation, a password reset, a sign-in link), and no notifications, digests or security alerts.

Cloudflare Turnstile

A check that the visitor is a person, before a form sends an email. Off by default.

  1. In the Cloudflare dashboard, open Turnstile, add a widget with this site’s domain, and copy its two keys.
  2. Tick Enable Cloudflare Turnstile, fill in Site key and Secret key, and press Save Turnstile settings.

The secret key is checked with Cloudflare when you save; a key Cloudflare does not recognise is refused and nothing is saved. Once saved, the field shows Saved. Leave blank to keep it and the key is never shown again.

With Turnstile on, the sign-up, registration link, password reset, magic link and confirmation resend forms show the check, and a request without a passed check is refused before it counts against any limit above. If Cloudflare cannot be reached, the forms keep working on the request limits alone. If a visitor’s browser blocks Cloudflare’s script, the form says the verification could not load and that challenges.cloudflare.com must be allowed.

What it doesn’t do

  • The request limits can’t be changed on this page.
  • The sign-in form itself has no Turnstile check; it is protected by its limit on failed attempts.
  • A sign-up form your developers built themselves is protected only if they add the checks to it.

For developers

  • The limits are in config :phoenix_kit, PhoenixKit.Users.RateLimiter; registration_global_limit is the sign-up cap (nil switches it off). RateLimiter.overview/0 returns what the table shows.
  • Your own public sign-up form should call Auth.register_user/3 with site_wide: true to share the cap, and check_email_domain: true for the email check.
  • For Turnstile on your own form, add <.turnstile_widget id="…" /> inside it and call PhoenixKitWeb.Users.BotCheck.run/3 first in its submit. Turnstile needs the phoenix_kit.js that mix phoenix_kit.update installs, and a Content-Security-Policy must allow https://challenges.cloudflare.com in script-src and frame-src.
  • A test suite that signs up through the kit’s form with @example.com addresses sets config :phoenix_kit, :email_domain_check, false in config/test.exs.