Apereo CAS - Google reCAPTCHA Integration

This blog is managed and hosted on GitHub. If you wish to update the contents of this post or if you have found an inaccuracy and wish to make corrections, we recommend that you please submit a pull request to this repository.


reCAPTCHA is a Google service that protects websites from spam and abuse. It uses advanced risk analysis techniques to tell humans and bots apart. This brief demonstrates how Apereo CAS may be configured to integrate with the Google reCAPTCHA API v2 and v3.

Our starting position is based on:



Let’s register our CAS server instance with Google to obtain a few integration keys:


Next, once the reCAPTCHA module is included in the WAR Overlay, we can begin to register the integration keys with CAS configuration:


That should be all. Build and deploy and the very next time you bring up the CAS login screen, you should automatically be presented with reCAPTCHA:



Integration with reCAPTCHA v3 is exactly the same; you will need to register CAS with Google reCAPTCHA v3 again to obtain v3-specific integration keys. Then, the reCAPTCHA version needs to be updated to match the integration version:



Google reCAPTCHA returns a score (1.0 is very likely a good interaction, 0.0 is very likely a bot). Based on the score, one can take variable action in a specific context. By default, CAS allows for a static single score in the configuration that is compared against the reCAPTCHA response. If the returned score is less than what CAS requires, the authentication attempt would be blocked.



You can of course inject your own reCAPTCHA validation logic into CAS for more advanced scenarios. To supply your own validator, you should start by designing your own configuration component to include the following bean:

public Action validateCaptchaAction() {
    return new MyValidateCaptchaAction(...);

All you would have to do is to implement the org.springframework.webflow.execution.Action interface in the MyValidateCaptchaAction.


I hope this review was of some help to you and I am sure that both this post as well as the functionality it attempts to explain can be improved in any number of ways. Please know that all other use cases, scenarios, features, and theories certainly are possible as well. Feel free to engage and contribute as best as you can.

Finally, if you benefit from Apereo CAS as free and open-source software, we invite you to join the Apereo Foundation and financially support the project at a capacity that best suits your deployment. If you consider your CAS deployment to be a critical part of the identity and access management ecosystem and care about its long-term success and sustainability, this is a viable option to consider.

Happy Coding,

Misagh Moayyed

Related Posts

CAS 6.2.0 RC1 Feature Release

...in which I present an overview of CAS 6.2.0 RC1 release.

Apereo CAS - JMeter Performance Testing

Learn to Performance Test Apereo CAS.

Apereo CAS - OAuth JWT Access Tokens

Learn to customize Apereo CAS to issue OAuth Access Tokens as JWTs.

CAS 6.2.x Deployment - WAR Overlays

Learn how to configure and build your own CAS deployment via the WAR overlay method, get rich quickly, stay healthy indefinitely and respect family and friends in a few very easy steps.

Apereo CAS 6.2.x - Building CAS Feature Modules

An overview of how various CAS features modules today can be changed and tested from the perspective of a CAS contributor working on the codebase itself to handle a feature request, bug fix, etc.

Apereo CAS - Service Redirection Strategies

Learn to customize Apereo CAS to modify the default strategy used for redirecting the authentication flow back to relying parties.

Apereo CAS - Service Matching Strategies

Learn to customize Apereo CAS to modify the default strategy used for matching services.

Apereo CAS - Password Management with JDBC

Learn use the Password Management features in Apereo CAS.

Apereo CAS - Simple Multifactor Authentication

Learn to configure Apereo CAS to act as a simple multifactor provider itself.

Apereo CAS 2019 Survey Results

...in which I present a summarized view of the latest CAS community survey.