Apereo CAS - Slurp Configuration with Groovy

The 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.

CAS allows you to externalize your configuration settings so you can work with the same CAS instance in different environments. You can use properties files, YAML files, environment variables and command-line arguments (just to name a few!) to externalize and provide configuration. These strategies present a very flexible and powerful way to manage CAS configuration for production deployments in a variety of use cases.

As your CAS deployment moves through the deployment pipeline from dev to test and into production, you can manage the configuration between those environments separately, and be certain that each tier has everything it needs to run when the server migrates. Tier-specific configuration is usually managed and activated through the use of application (aka. Spring) profiles while the rest of the more common settings are gathered centrally that apply to all environments. When you run CAS in standalone mode specially, the default configuration directory on the filesystem (i.e. /etc/cas/config) may include (cas|application).(yaml|yml|properties) files that can be used to control behavior. Such configuration files may also specifically apply to a profile (i.e. ldap.properties) that can be activated using spring.profiles.active or spring.profiles.include settings.

Starting with CAS 6, Groovy can also serve as a strategy for loading configuration in a way that allows one to consolidate common and tier-specific files in one place. This tutorial explores that possibility with a starting position is based on the following:

  • CAS 6.0.0-RC4
  • Java 11
  • CAS Overlay (The master branch specifically)

Groovy ConfigSlurper

If you are familiar with Groovy, then ConfigSlurper is no stranger to you. This is a utility class for reading configuration files defined in the form of Groovy scripts. Configuration settings can be defined using dot notation or scoped using closures:

 grails.webflow.stateless = true
 smtp {
     mail.host = 'smtp.myisp.com'
     mail.auth.user = 'server'
 resources.URL = "http://localhost:80/resources"

CAS takes advantage of this very component, allowing you to isolate tier-specific settings in form of conditional closures. In the simplest scenario, it expects to find a cas.groovy file in the same configuration directory while running standalone mode that might look like this:

profiles {
    dev {
    prod {


When you run CAS using the dev profile, the collection of settings that are picked up from the script are:


…and when you run CAS using the prod profile, the collection of settings that are picked up from the script are:


For small configuration changes between tiers, this is arguably simpler than having, for example, cas.properties, dev.properties and prod.properties files. For anything else larger and more complicated, you still may want to think about separating settings into multiple files or perhaps consider using the Spring Cloud Config Server.


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 feel free to engage and contribute as best as you can.

Misagh Moayyed

Related Posts

CAS 6.2.0 RC3 Feature Release

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

Checking Out Pull Requests Locally

Check out GitHub pull requests as local branches using a simple bash function.

CAS 6.2.0 RC2 Feature Release

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

Apereo CAS - Authentication Handler Resolution

Learn how to resolve and select authentication handlers based on configurable and flexible filtering criteria.

CAS Vulnerability Disclosure

Disclosure of a security issue with the CAS software.

Apereo CAS - SAML2 Metadata Overrides

Learn how to manage SAML2 service provider registrations in CAS and override metadata artifacts on a per-application basis.

Apereo CAS - Managing Configuration Metadata

Learn how to manage CAS configuration and properties using Spring Boot Configuration metadata.

CAS 6.2.0 RC1 Feature Release

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

Apereo CAS - Deployment Using systemd

Fabio Martelli of Tirasa S.r.l reviews the setup required to deploy Apereo CAS as a system service using systemd.

Apereo CAS - Python Locust Load Testing

Learn to Performance Test Apereo CAS with Python Locust.