DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Beyond SOLID: Embracing CUPID for Modern Software Craftsmanship
  • Beyond Conversation: Mastering Context with Claude Code Skills and Agents
  • Clean Code: Interfaces in Go — Why Small Is Beautiful, Part 3
  • Unified CI/CD Interface: Strategic DevOps Acceleration

Trending

  • Ujorm3: A New Lightweight ORM for JavaBeans and Records
  • Building an Image Classification Pipeline With Apache Camel and Deep Java Library (DJL)
  • End-to-End Event Streaming With Kafka, Spring Boot and AWS SQS/SNS (Production-Ready Code Guide)
  • RAG Done Right: When to Use SQL, Search, and Vector Retrieval and How To Combine Them
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. How to Customize User Interface in Apereo CAS

How to Customize User Interface in Apereo CAS

Check out this simplified guide to start using Apereo CAS and learn how to customize the user interfaces of a CAS application.

By 
Upul Kamburawala user avatar
Upul Kamburawala
·
Oct. 25, 21 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
5.5K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, we are going to see how to customize the user interfaces of a CAS application. 

As you may know already, we are dealing with WAR overlay installation of the CAS project. Within this overlay project, there are no view pages available for us to modify. So first of all, we need to bring down any CAS views which we need to modify into our overlay from the CAS source code.

How to Customize a CAS View

As the first step, on the command prompt, go to the  root folder of your CAS overlay project and give the following command, in order to see all available CAS views:

gradlew listTemplateViews

If you want to bring down the CAS login view to our overlay project, use the following command:

gradlew getResource  –P resourceName= casLoginView.html

Then “casLoginView.html” should be available in “src/main/resources/templates/” folder of your overlay.

If you like, you can unzip the CAS web application and the internal resource jar using the following command:

graldew explodeWar

Now you can manually copy the required HTML file into “src/main/resources/templates/” and then modify it.

Note: After unzipping the resource jar, the “getResource” command may fail with the message “cas-server-webapp-resources-XXX.jar’ does not exist. In that case, all the views may be available “build\cas\WEB-INF\classes\templates” folder.

You can see CAS views consist of smaller fragments which are available in “src/main/resources/templates/fragments” folder. If you need to modify a specific part of the login page for example either header or footer, then you need to modify the relevant fragment available in this folder. You can even add your own fragment in this folder and then modify “casLoginView.html” in the following way:

HTML
 
<div th:if="${headersList}">
   <div class="row">
	<div id="headers" class="headerlist-panel col-12" th:if="${headersList != null}">
		<div th:replace="fragments/headerslist :: headerslist">
		  <a href="fragments/headerslist.html">headers list goes here</a>
		</div>
 	</div>
   </div>
</div>


In the above example “headerList” is a list of items passing from the backend (when the login page is loading). If the “headerList” parameter has a value, then “headerlist.html” fragment will be displayed on the login page. Inside “headerlist.html” fragment, you can have coding to iterate the list and display them.

Note: CAS uses "Thymeleaf" for markup rendering. So to modify CAS view, you must have a bit of the basics of Thymeleaf.

CSS, images, and JavaScript files should be in the “src/main/resources/static/” folder and they should have their own folders respectively “css”, “Images” and “js”. If you want to modify the default “cas.css” file, you can do so by bringing it down and placing that file inside “src/main/resources/static/css” folder. Instead of modifying the above default “cas.css” file, if you want to have your own cutom.css file, then you want to modify the “cas.standard.css.file” property inside the “cas-theme-default.properties” file located inside“src/main/resources/” folder.

All UI messages appearing in the views are available “messages.properties” file inside the resource folder. However, if you want to overwrite those default messages or add some additional messages, CAS recommended way to do so, is placing them in “custom_messages.properties” file which you should place inside “src/main/resources” folder. 

The following is how the folder structure of the “src/main/resources” folder would look like in a CAS overlay project.

“src/main/resources” folder

 

Now we have some idea of modifying CAS views and where to place those files inside our project. Next time when we build our overlay project, it will pick up files available (i.e. modification to the views we have done) inside “src/main/resources” folder of the overlay project.  So once it will be up and running, we can see the modification we have done.

Central Authentication Service Interface (computing)

Opinions expressed by DZone contributors are their own.

Related

  • Beyond SOLID: Embracing CUPID for Modern Software Craftsmanship
  • Beyond Conversation: Mastering Context with Claude Code Skills and Agents
  • Clean Code: Interfaces in Go — Why Small Is Beautiful, Part 3
  • Unified CI/CD Interface: Strategic DevOps Acceleration

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook