Coder Social home page Coder Social logo

viraja1 / keycloak-login-recaptcha Goto Github PK

View Code? Open in Web Editor NEW

This project forked from raptor-group/keycloak-login-recaptcha

0.0 2.0 0.0 22 KB

By default Keycloak ( up to 4.4.0) only supports ReCaptcha for Regsitration, not login. so we created a simple module for activating recaptcha for login

License: Apache License 2.0

Java 100.00%

keycloak-login-recaptcha's Introduction

keycloak-login-recaptcha

By default Keycloak (up to 4.4.0) only supports ReCaptcha for Registration, not Login. This module allows you to enable ReCaptcha for Login.

How to use

For building it you need to run mvn clean install. It will produce a jar target/recaptcha-login.jar. For making it accessible in Keycloak you should copy this jar into Keycloak's standalone/deployments/ directory.

If you're using it in docker environment, then you should mount it in /opt/jboss/keycloak/standalone/deployments/recaptcha-login.jar

Docker Compose file Example:

...
keycloak:
	image: jboss/keycloak:4.2.1.Final
	.
	.
	.
	volumes:
		- ./keycloak-login-recaptcha/target/recaptcha-login.jar:/opt/jboss/keycloak/standalone/deployments/recaptcha-login.jar
...

Add the following piece of code in your login.ftl template file:

<#if recaptchaRequired??>
<div class="form-group">
	<div class="${properties.kcInputWrapperClass!}">
		<div class="g-recaptcha" data-size="compact" data-sitekey="${recaptchaSiteKey}">			
		</div>
	</div>
</div>
</#if>

You should paste it inside your login <form></form> in your login template (login.ftl)

Path of login.ftl inside docker container - /opt/jboss/keycloak/themes/base/login/login.ftl

reCAPTCHA Support

To safeguard registration against bots, Keycloak has integration with Google reCAPTCHA. To enable this you need to first go to Google Recaptcha Website and create an API key so that you can get your reCAPTCHA site key and secret.

Next, there are a few steps you need to perform in the Keycloak Admin Console. Click the Authentication left menu item and go to the Flows tab. Select the Browser flow from the drop down list on this page. Click on the copy button so that you can copy this flow and give it a name "Login with captcha". After this is done, then you will see "Auth Type" column on the left side of the page. Go to the row where "Auth Type" is "Login with captcha". Then click on "Actions" hyperlink. Then click on "Add execution" and select "Recaptcha Username Password Form" from the dropdown and click on save. Then click on "Actions" hyperlink for "Recaptcha Username Password Form". Then click on config and fill google reCaptcha details and click on save. Then delete "Username Password Form" by clicking on "Actions hyperlink". Finally move "Recaptcha Username Password Form" before "OTP Form" by clicking on up arrow button in the UI. Then select "REQUIRED" option for "Recaptcha Username Password Form". Finally click on "Bindings" tab and select "Login with captcha" for Browser Flow and click on save.

You should also enable external origin https://google.com as mentioned in keycloak documentation. Recaptcha Documentation

Keycloak Security Headers

keycloak-login-recaptcha's People

Contributors

viraja1 avatar unikzforce avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.