CAS 5.0.2 and customized theme

1,201 views
Skip to first unread message

Matthieu Marc

unread,
Jan 23, 2017, 8:18:17 AM1/23/17
to CAS Community
Hi,

I am using CAS 5.0.2 and cas-maven-overlay.

I am trying to create a custom theme named "ensam".

In cas.properties, I added following lines in order to make my theme the default theme.

cas.theme.paramName=theme
cas
.theme.defaultThemeName=ensam


I create folder src/main/resources/templates/ensam and copied default views file in it. So that, I get src/main/resources/templates/ensam/casLoginView.html

I changed this file.

When I start CAS service (./build.sh run) and go to url /cas/login, I do not see my modification.

In log, I got following :

2017-01-23 13:25:10,220 DEBUG [org.apereo.cas.services.web.RegisteredServiceThemeBasedViewResolver] - <Found view ensam/casLoginView>
2017-01-23 13:25:10,265 DEBUG [org.apereo.cas.services.web.ServiceThemeResolver] - <Found custom theme [ensam] for service [id=1000......]

In my cas-overlay-template directory, I can find the file in theses places :

find ./ -name casLoginView.html
./src/main/resources/templates/ensam/casLoginView.html [my original file]
./target/war/work/org.apereo.cas/cas-server-webapp/WEB-INF/classes/templates/casLoginView.html  [file without my changed]
./target/cas/WEB-INF/classes/templates/casLoginView.html [file from maven dependencies - without my changed]
./target/cas/WEB-INF/classes/templates/ensam/casLoginView.html [my file with changes]
./target/classes/templates/ensam/casLoginView.html [my file with changes]

What I missed to make my theme working ?

Thanks

Jonathan Franzone

unread,
Jan 27, 2017, 11:38:58 AM1/27/17
to CAS Community
I'm trying to resolve this exact issue myself. If anyone has the answer or finds it, can they please post for all? Thanks!

HURTEVENT VINCENT

unread,
Jan 27, 2017, 12:17:40 PM1/27/17
to cas-...@apereo.org
Hi,

It seems that your cas.properties «  cas.theme.defaultThemeName=ensam » is not applied.

I didn’t try the 5.0.x version yet, and the documentation says cas.theme.deaultThemeName, but did you try the 4.x way with : cas.themeResolver.defaultThemeName ?

When you try to login into the service found as said in your log 

2017-01-23 13:25:10,265 DEBUG [org.apereo.cas.services.web.ServiceThemeResolver] - <Found custom theme [ensam] for service [id=1000......]

Do you get your ENSAM theme ?





--
- CAS gitter chatroom: https://gitter.im/apereo/cas
- CAS mailing list guidelines: https://apereo.github.io/cas/Mailing-Lists.html
- CAS documentation website: https://apereo.github.io/cas
- CAS project website: https://github.com/apereo/cas
---
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/69640534-e1c9-4ea3-9e6f-7d9138f4b1d9%40apereo.org.

Jonathan Franzone

unread,
Jan 27, 2017, 1:06:37 PM1/27/17
to CAS Community
Update on my work towards resolving this issue. To try to find the root of the problem, I completely removed all of the default theme template files, leaving just my personalized ones. That resulted in an exception being thrown (some sort of Thymleaf parse exception). This leads me to believe that if there is a parse exception that the software will fall back to the default templates.

Going on that assumption, I modified my casLoginView.html template to just include HTML (no thymleaf instructions). It was basically a Hello World html file. I restarted Tomcat and bingo! it pulled up my theme file.

So no I just have to resolve what those parse exceptions are. Not a full solution, but hopefully it'll get you onto the right path and serve as a record of what is going on.


On Monday, January 23, 2017 at 7:18:17 AM UTC-6, Matthieu Marc wrote:

Jonathan Franzone

unread,
Jan 27, 2017, 1:18:56 PM1/27/17
to CAS Community
Ah! I've got it working for me now. The issue in my case was twofold:

1) I had an error in my layout file, which caused things to fall back to the default theme

2) On all of my fragment includes, I needed to specify my theme.

So instead of:
<div threplace="fragments/loginform" />


Put:
<div threplace="ensam/fragments/loginform" />


Hope that helps!

On Monday, January 23, 2017 at 7:18:17 AM UTC-6, Matthieu Marc wrote:

Matthieu Marc

unread,
Jan 30, 2017, 9:43:10 AM1/30/17
to jasig-cas-user, cas-...@apereo.org, vincent....@univ-lyon1.fr
Hi,

I tried cas.themeResolver without success. 

When I got the log, I didn't have my theme applied. I follow Jonathan Franzone explains, and modifying my theme file make it working. Just copying the default theme and adding a div do not work. We have to change fragments path....

I need now to understand how thymeleaf is working because change I made are not applyed as wanted.


Cdly,

Tim McLaughlin

unread,
Feb 17, 2017, 2:04:06 PM2/17/17
to CAS Community

Interesting -- I am experiencing this, as well.  The custom CSS file listed in /resources/theme-name.properties are being used, but the custom casLoginView.html is not.  It is working correctly for services where I have specified a theme, but not for the case where no service is specified in the URL.


If I come across any other information, I'll add to this thread.


Tim


From: cas-...@apereo.org <cas-...@apereo.org> on behalf of Jonathan Franzone <jonathan...@gmail.com>
Sent: Friday, January 27, 2017 10:06:37 AM
To: CAS Community
Subject: [cas-user] Re: CAS 5.0.2 and customized theme
 
--
- CAS gitter chatroom: https://gitter.im/apereo/cas
- CAS mailing list guidelines: https://apereo.github.io/cas/Mailing-Lists.html
- CAS documentation website: https://apereo.github.io/cas
- CAS project website: https://github.com/apereo/cas
---
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.

Ashley Mort

unread,
Jun 13, 2017, 10:17:21 AM6/13/17
to CAS Community
I am using CAS 5.0.6 and trying to make a custom Login Page.  Can anyone share their code or point to a resource of how to learn how to customize the Login Page?  What resources did you guys use for reference to get started on this type of task?  


On Monday, January 23, 2017 at 7:18:17 AM UTC-6, Matthieu Marc wrote:

Christian Poirier

unread,
Apr 27, 2018, 11:03:48 AM4/27/18
to CAS Community, ashle...@gmail.com
I am using the 5.3 RC3 and I have the same problem. The theme css and javascript are loaded and I have an error when I change the path of inclusion (th:replace href) by prefixing with the <theme name>, ex.: <theme name>/fragments/loginform.html, I still not see my changes made from <theme name>fragments/loginform.html.

Christian Poirier

unread,
Apr 27, 2018, 11:29:45 AM4/27/18
to CAS Community
Thanks to Jonathan for giving us a hint that it works. Indeed, I added the name of the theme in prefix to the path in the clause "th:replace" and in the clause "href". 

The loginView.html file for my theme was used, but the inclusion of the loginform.html file was the default theme.

Mohannad Henno

unread,
May 31, 2018, 10:27:31 AM5/31/18
to CAS Community
Hi,

Did you guys had this working?

I am having the same problem when loading my custom template files. The inclusive fragments are loaded from the original folder instead of my custom theme although I have used the prefix in the "replace" tag.

Best Regards,
Mohannad

David Curry

unread,
May 31, 2018, 11:16:52 AM5/31/18
to cas-...@apereo.org
You need to change the line near the top of each view that includes "layout.html" to include "yourtheme/layout.html" instead.

--

DAVID A. CURRY, CISSP
DIRECTOR OF INFORMATION SECURITY
INFORMATION TECHNOLOGY

71 FIFTH AVE., 9TH FL., NEW YORK, NY 10003
+1 212 229-5300 x4728david...@newschool.edu

The New School



--
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG

---
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.

Mohannad Henno

unread,
Jun 3, 2018, 2:50:24 AM6/3/18
to CAS Community
Thank you David!

Your suggestion solved the issue.

Best Regards,
Mohannad
Reply all
Reply to author
Forward
0 new messages