SSO
Cloudflare Turnstile in Authentik - Setting Up Login Form Protection
Also available in: RU

Part 7 of 9 in the series Authentik
- Authentik Overview - Architecture, Features, and Comparison with Keycloak
- OIDC, OAuth2, and Proxy Provider in Authentik - How to Protect Any Application
- Authentik - Initial Setup After Installation
- Setting Up Password Recovery in Authentik
- Setting Up User Enrollment and Invitation Processes in Authentik
- Setting Up Two-Factor Authentication in Authentik
- Cloudflare Turnstile in Authentik - Setting Up Login Form Protection
- Setting Up Email Notifications in Authentik
- Authentik - Setting Up a Reputation Policy
Contents
Update, October 10, 2026: this method no longer works in Russia. The Turnstile widget is loaded from Cloudflare's servers (challenges.cloudflare.com), and access to them is restricted by Russian ISPs. For a user in Russia the widget simply never shows up, the check can't be passed - and the login form won't let them through. So instead of bot protection, you end up locking yourself out. If your users (or you) access Authentik from Russia, don't enable Turnstile. What you can use instead:
- the Reputation Policy - built-in protection against password guessing that doesn't call out to anything external;
- Cap - a CAPTCHA you can host on your own server; Authentik supports it in the same
Captcha Stage(see the docs).
The article is still relevant if your users are outside Russia.
I'm assuming you already have Authentik installed and configured (see the initial setup article, and also OIDC, OAuth2, and Proxy Provider if you're protecting a third-party app). Cloudflare Turnstile is a modern alternative to CAPTCHA that lets you protect authentication forms from bots and brute-force attacks without forcing users to decipher images or type in characters.
If you enjoyed this article, you can become a sponsor on Boosty.
Cloudflare Turnstile is an analog of Captcha technology, but for Cloudflare users. If you specifically need to set up Captcha, you can read more in the official documentation
As of July 1, 2025, changes to Russian personal data legislation (Federal Law No. 152) came into effect, under which using Google reCAPTCHA or its analogs on sites that transfer data abroad becomes a violation. Keep this restriction in mind if you plan to use this service for commercial activity.
Why use Cloudflare Turnstile in Authentik
By default, Authentik already has decent protection against:
- brute-force attacks;
- username enumeration;
- automated login attempts.
However, when exposing your IdP to the internet, this is often not enough.
Cloudflare Turnstile lets you:
- filter out bots before they even get to the password;
- reduce the load on Authentik;
- improve the user experience compared to classic CAPTCHAs;
- raise the overall security level without complicating your flow logic.
In other words, in addition to the authentication and authorization methods we already set up in previous articles, we're adding one more verification method.
Visually, it looks something like this

Requirements
Before you start, make sure you have a Cloudflare account - a free one is enough.
The domain Authentik runs on doesn't have to be moved to Cloudflare: Turnstile works on any website, and you just enter the domain name when creating the widget. The exception is Pre-Clearance mode, covered below.
Creating a Turnstile widget in Cloudflare
- Go to the Cloudflare dashboard.
- Open the Security > Turnstile section (Cloudflare periodically moves menu items between sections - at the time of writing this was under "Protect & Connect", now it's moved to "Security". If you still can't find it, just search for "Turnstile" in the dashboard search).
- Click Add Widget (in some UI versions the button is already called Add site).
- Specify:
- Widget name - any name you like (e.g.
authentik-login); - Add Hostname > Domains - the domain where Authentik runs;
- Widget mode - Managed (recommended for home use).
- Pre-Clearance Mode - Yes
- Level of pre-clearance - interactive
- Widget name - any name you like (e.g.
Change the last two settings however you see fit, depending on your needs and level of paranoia. Pre-Clearance only makes sense when the domain itself is served through Cloudflare and has protection rules set up there. If your domain isn't on Cloudflare, set it to No.

Once created, you'll receive:
- Site Key
- Secret Key
You can copy them, but Cloudflare kindly notes that you'll always be able to access them again later.

Creating a Captcha Stage in Authentik
Configuring the stage in Authentik
Now let's move on to the configuration in Authentik.
- Open the Authentik admin panel.
- Go to Flows and Stages → Stages.
- Click Create.
- Select Captcha Stage.

- Give the stage a name.
- For the verification type, select Cloudflare Turnstile.
- In the
Public keyandPrivate Keyfields, enter the values we got from Cloudflare. - You can leave the
Interactivetoggle enabled if your Turnstile is configured asInvisibleorManaged.
Don't touch anything in the Advanced Settings section. In the version of Authentik current as of writing, the correct values are already filled in automatically. Previously you had to enter them manually. You can read more in the official documentation

- Finish
Integrating the Turnstile stage into the main authentication and authorization flow
- Open the
Authentikadmin panel. - Go to Flows and Stages → Flows → default-authentication-flow.
- Select Stage Bindings → Bind Existing Stage
- Select the stage we just created.
- Choose the processing order for the Turnstile stage - after the identification stage (where the username is entered), but before the password entry stage.
- Select
evaluate when flow is planned. - Create

We've now integrated the "captcha" stage into Authentik's authentication process.

Set up this way, the captcha is shown to every user on every login. If you'd rather show it only to suspicious requests - say, after a few failed login attempts from the same IP - attach a Reputation Policy to this stage binding (without Negate the result) and switch the binding to evaluate when stage is run. I covered how that policy works in Authentik - Setting Up a Reputation Policy.
Test the login in a separate incognito window without closing your admin session. If the widget fails to load, you won't be able to get from the login form into the admin panel to turn the stage off. For that case there's an emergency way in: docker exec authentik_server ak create_recovery_key 10 <admin_username> prints a link that's valid for 10 minutes and logs you in as the given user, bypassing the login form. After that you can unbind the Turnstile stage from the flow.
In the Turnstile panel on the Cloudflare site, you can view analytics for this widget




