templatesthemescasapereo

Apereo CAS HTML template does not seem to load


So I initialized CAS using cas-initializr with the following command inside the cas folder:

curl https://casinit.herokuapp.com/starter.tgz -d "dependencies=core,bootadmin,metrics,gitsvc,jsonsvc,redis,support-themes-core" | tar  -xzvf -

My theme name is example. Here is the file structure of cas/src/main/resources/templates:

templates
├── META-INF
│   └── spring.factories
├── application.yml
├── example.properties
├── static
│   └── themes
│       └── example
│           ├── css
│           │   └── cas.css
│           ├── images
│           │   ├── favicon.ico
│           │   └── logo.png
│           └── js
│               └── cas.js
└── templates
    └── example
        └── casLoginView.html

The content of casLoginView.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>Hello World!</h1>
</body>
</html>

The content of example.properties:

cas.theme.name=Example Theme
cas.theme.description=Example - Central Authentication Service

cas.standard.css.file=/themes/example/css/cas.css
cas.standard.js.file=/themes/example/js/cas.js
cas.logo.file=/themes/example/images/logo.png
cas.favicon.file=/themes/example/images/favicon.ico

cas.drawer-menu.enabled=false
cas.notifications-menu.enabled=false
cas.login-form.enabled=true

My cas.properties file located at /etc/cas/config/:

cas.server.name=https://localhost:8443
cas.server.prefix=${cas.server.name}/cas

cas.serviceRegistry.json.location=file:/etc/cas/services
# cas.authn.accept.enabled=false

server.ssl.key-store=file:/etc/cas/thekeystore
server.ssl.key-store-password=changeit

cas.theme.defaultThemeName=example
spring.thymeleaf.cache=false

After I started the server with ./gradlew bootRun, I opened https://localhost:8443/cas/login on my chrome browser. The CSS, Image and JS seems to load fine (I confirmed it using Chrome Devtool), but the default template was used instead of my custom template.

I had tried googling around for several hours now and I still can't figure out how to make cas load my html template.

P/s: I tried moving all the resources content to cas/build/resources, cas/build/resources/main but it does not seem to work either.


Solution

  • Starting with 6.4 RC5 (which is the version you run as of this writing and should provide this in your original post):

    The collection of thymeleaf user interface template pages are no longer found in the context root of the web application resources. Instead, they are organized and grouped into logical folders for each feature category. For example, the pages that deal with login or logout functionality can now be found inside login or logout directories. The page names themselves remain unchecked. You should always cross-check the template locations with the CAS WAR Overlay and use the tooling provided by the build to locate or fetch the templates from the CAS web application context.

    https://apereo.github.io/cas/development/release_notes/RC5.html#thymeleaf-user-interface-pages

    Please read the release notes and adjust your setup.

    All templates are listed here: https://apereo.github.io/cas/development/ux/User-Interface-Customization-Views.html#templates