Skip to content
Grails Jpcatcha spring security plugin
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Grails Jpcatcha spring security plugin

Jcaptcha spring security plugin integrates Jcaptch plugin with spring security core plugin

Installing the plugin

grails {
	project {
		dependency.resolution = {
			repositories {
				//below two repositories are needed by jcaptcha
				mavenRepo ''
				mavenRepo ''




plugins {
    compile ':jcaptcha-spring-security:0.1'


Jcaptcha spring security plugin needs a catcha with name 'login' to be defined in configuration. See Jcaptch plugin for how to configure jcaptchas



jcaptchas {
	login = new GenericManageableCaptchaService(
		new GenericCaptchaEngine(
			new GimpyFactory(
				new RandomWordGenerator(
				new ComposedWordToImage(
					new RandomFontGenerator(
						20, // min font size
						30, // max font size
						[new Font("Arial", 0, 10)] as Font[]
					new GradientBackgroundGenerator(
						140, // width
						35, // height
						new SingleColorGenerator(new Color(0, 60, 0)),
						new SingleColorGenerator(new Color(20, 20, 20))
					new NonLinearTextPaster(
						6, // minimal length of text
						6, // maximal length of text
						new Color(0, 255, 0)
		180, // minGuarantedStorageDelayInSeconds
		100000, // maxCaptchaStoreSize

Add following lines to your config.groovy

grails {
	plugin {
		jcaptchaspringsecurity {
			enabled = true
			time = 5
			allowedNumberOfAttempts = 3

time - Time in minutes to remember the failed attempts (eg. 3 failed attempts in last 5 minutes) allowedNumberOfAttempts - Allowed number of attempts after which captcha should be displayed.

Add captcha to the login form.

Plugin provides a tag jcaptchaLogin which can be used to render the captcha for login form.

Add following lines to loginform.


It will display the image captcha along with the input text field after allowed number of failed login attempts.

Customize the captcha style / markup

You can override the template by copying /templates/_jcaptchaLogin.gsp from plugin to your application at path grails-app/views/templates/_jcaptchaLogin.gsp. And customize it as per your need.

You can’t perform that action at this time.