Keycloak CAPTCHA Plugin
The following tutorial will guide you on how to integrate the TrustCaptcha CAPTCHA solution into your Keycloak website to protect it from bots and spam.
Preparation
Section titled “Preparation”You should have already completed the following steps before you start to integrate TrustCaptcha into your Keycloak website.
Read Get-Started: Get a quick overview of the concepts behind TrustCaptcha and the integration process in get started.
Existing CAPTCHA: If you don’t have a CAPTCHA yet, sign in or create a new user account. Then create a new CAPTCHA.
Existing Keycloak website: You need a Keycloak website in which you want to integrate TrustCaptcha.
Supported Keycloak Flows
Section titled “Supported Keycloak Flows”Keycloak uses flows that you can edit and customize. Our Keycloak CAPTCHA extension for TrustCaptcha currently supports the following Keycloak flows:
- Registration
- Login
- Forgot Password
Installation
Section titled “Installation”Install our TrustCaptcha plugin into your Keycloak installation as follows:
- Download the latest version of our plugin trustcaptcha_keycloak_2-0-0.jar here.
- Copy the file
trustcaptcha_keycloak_2-0-0.jarto theprovidersdirectory of your Keycloak installation.
Configuration
Section titled “Configuration”The following guides (and practical video examples) show you how to integrate TrustCaptcha into various Keycloak flows.
Registration
Section titled “Registration”Steps to integrate TrustCaptcha into your registration flow:
- Log in as an admin to your Keycloak installation.
- In your realm, navigate to
Authentication → Flows. - Duplicate the existing
registrationflow, give it a new name (e.g., Registration (TrustCaptcha)) and confirm the duplication. - Click on the top step, then click
Add → Add step. Search forTrustCaptcha / Registration Form Actionand add this step. - Position the new
TrustCaptchastep at the same level above or below the existingRecaptchastep and then delete the Recaptcha step. - Open the
Settingsof the new TrustCaptcha step, set theAlias(e.g., tc-registration), enter your CAPTCHA’ssite-keyandsecret-key, and save the settings. You can find these keys in your CAPTCHA settings. - Finally, click on
Actions → Bind flow. Select the flow typeRegistration flowand clickSave. - TrustCaptcha is now ready for use in the registration form! 🎉
The video visually demonstrates the most important steps.
Steps to integrate TrustCaptcha into your login flow:
- Log in as an admin to your Keycloak installation.
- In your realm, navigate to
Authentication → Flows. - Duplicate the existing
browserflow, give it a new name (e.g., Browser (TrustCaptcha)) and confirm the duplication. - Click on
Add step. Search forTrustCaptcha / Username Password Formand add this step. - Position the new
TrustCaptchastep at the same level above or below the existingUsername Password Formstep and then delete the Username Password Form step. - Open the
Settingsof the new TrustCaptcha step, set theAlias(e.g., tc-login), enter your CAPTCHA’ssite-keyandsecret-key, and save the settings. You can find these keys in your CAPTCHA settings. - Finally, click on
Actions → Bind flow. Select the flow typeBrowser flowand clickSave. - TrustCaptcha is now ready for use in the login form! 🎉
The video visually demonstrates the most important steps.
Forgot Password
Section titled “Forgot Password”Steps to integrate TrustCaptcha into your forgot password flow:
- Log in as an admin to your Keycloak installation.
- In your realm, navigate to
Authentication → Flows. - Duplicate the existing
reset credentialsflow, give it a new name (e.g., Reset Credentials (TrustCaptcha)) and confirm the duplication. - Click on
Add step. Search forTrustCaptcha / Reset Credentials Choose Userand add this step. - Position the new
TrustCaptchastep at the same level above or below the existingChoose Userstep and then delete the Choose User step. - Open the
Settingsof the new TrustCaptcha step, set theAlias(e.g., tc-reset), enter your CAPTCHA’ssite-keyandsecret-key, and save the settings. You can find these keys in your CAPTCHA settings. - Finally, click on
Actions → Bind flow. Select the flow typeReset credentials flowand clickSave. - TrustCaptcha is now ready for use in the forgot password form! 🎉
The video visually demonstrates the most important steps.
Template
Section titled “Template”TrustCaptcha offers two options for frontend integration:
Insert Automatically
Section titled “Insert Automatically”With this option, TrustCaptcha automatically integrates into the existing login, registration, and forgot password forms of Keycloak. TrustCaptcha looks for button or input elements with type="submit" and integrates itself above them.
Custom Templates
Section titled “Custom Templates”If you don’t use button/input elements with type="submit", or you want to customize the CAPTCHA for design reasons, you can disable the Insert Automatically feature in the TrustCaptcha settings. You can then define a div container with the class trustcaptcha in your templates. TrustCaptcha will automatically integrate above this container.
Custom Template
<!-- your input fields -->
<div class="trustcaptcha"></div>
<!-- further input fields / submit button -->Next steps
Section titled “Next steps”Once you have successfully installed and configured TrustCaptcha on your website, you can use TrustCaptcha to its full extent. However, we still recommend the following additional technical and organizational measures:
Security rules: You can find many security settings for your CAPTCHA in the CAPTCHA settings. These include, for example, authorized websites, CAPTCHA bypass for specific IP addresses, bypass keys, IP based blocking, geoblocking, individual difficulty and duration of the CAPTCHA, and much more. Learn more about the security rules.
Data protection: Include a passage in your privacy policy that refers to the use of TrustCaptcha. We also recommend that you enter into a data processing agreement with us to stay GDPR-compliant. Learn more about data protection.
Accessibility: Customize TrustCaptcha to your website so that your website is as accessible as possible and offers the best possible user experience. More about accessibility.
Testing: If you use automated testing, make sure that the CAPTCHA does not block it. Learn more about testing.