Cas can’t see exteralized customised views. Cas overlay ver 6.3.2.

467 views
Skip to first unread message

artur miś

unread,
Mar 10, 2021, 10:36:28 AM3/10/21
to CAS Community

Gradle.properties

ss@zal:~/cas.6.3_10_10_2020_update/cas-overlay-template-master$ cat gradle.properties

cas.version=6.3.2

springBootVersion=2.3.4.RELEASE

appServer=-tomcat

executable=false

tomcatVersion=9.0.38

group=org.apereo.cas

sourceCompatibility=11

targetCompatibility=11

jibVersion=2.8.0

shellDir=build/libs

ivyVersion=2.4.0

gradleDownloadTaskVersion=4.1.1

gradleMavenPluginVersion=5.2.1

gradleLombokPluginVersion=5.2.1

baseDockerImage=adoptopenjdk/openjdk11:alpine-jre

allowInsecureRegistries=false



cas.propierties

spring.thymeleaf.prefix=classpath:/templates/

cas.view.template-prefixes[0]=file:///etc/cas/templates ← store for  views outside the cas.war




services:

ss@zal:/cas/cas7/services$ cat  prg-3.json

{

  "@class" : "org.jasig.cas.services.RegexRegisteredService",

  "serviceId" : "^(http|https|imaps)://newton.xx/.*",

  "name" : "PRG_PABLO",

  "id" : 3,

  "evaluationOrder" : 0,

  "theme" : "nextor",

   "authenticationPolicy" : {

    "@class" : "org.apereo.cas.services.DefaultRegisteredServiceAuthenticationPolicy",

    "requiredAuthenticationHandlers" : ["java.util.TreeSet", ["xxx",  "yyyy" ]]

  },

}


Copy templates outside the webapp:

cp -rp  :~/cas.6.3_10_10_2020_update/cas-overlay-template-master/src/main/resources /cas/cas7/templates

/cas/cas7$ ls

config  services  templates  thekeystore



Removing templates from cas overlay:

cd ~/cas.6.3_10_10_2020_update/cas-overlay-template-master/src/main/resources$ ls

messages_pl.properties  nextor.properties  static  templates

rm -rf templates



Theme files/tree:

ss@zal~/cas.6.3_10_10_2020_update/cas-overlay-template-master/src/main/resources$ cd static/

ss@zal:~/cas.6.3_10_10_2020_update/cas-overlay-template-master/src/main/resources/static$ ls

css  images  js  themes

ss@zal:~/cas.6.3_10_10_2020_update/cas-overlay-template-master/src/main/resources/static$ cd themes/

ss@zal:~/cas.6.3_10_10_2020_update/cas-overlay-template-master/src/main/resources/static/themes$ ls

nextor

ss@zal:~/cas.6.3_10_10_2020_update/cas-overlay-template-master/src/main/resources/static/themes$ cd nextor/

ss@zal:~/cas.6.3_10_10_2020_update/cas-overlay-template-master/src/main/resources/static/themes/nextor$ ls

css  images  js



Theme def:for service nextor

ss@zal~/cas.6.3_10_10_2020_update/cas-overlay-template-master/src/main/resources$ cat nextor.properties

cas.theme.defaultThemeName=nextor

cas.standard.css.file=/themes/nextor/css/cas.css

cas.standard.js.file=/themes/nextor/js/cas.js


Image creation:

./gradlew --info build jibDockerBuild


Creation container:

sudo docker run  --name cas2localTT    -v /cas/cas7:/etc/cas -p 127.0.0.1:4444:8443 -d org.apereo.cas/cas:latest



Result: 

reguest: https://sample.xx/casphp/login?service=https://newton.xx/

It is using files from  /etc/cas/templates  but only for  default files (/etc/cas/templates/fragments/footer.html)  . It doesn’t uses nextor views at all. I thought that if i have theme  nextor.properties it will be use  views defined in  folder templates/nextor .  Problably i have missed something  but i don’t know what. Could you help me please ?

How i menssioned before:

ss@zal/cas/cas7/templates$ ls

casLoginView.html  fragments  nextor

If i change footer.html i can see changes on website but if i change  footer.htm in nextor  i can not  see result.

Obviously if I  have all in  cas.war   I have customised  view nextor working.

Łukasz Woźniak

unread,
Mar 12, 2021, 4:49:39 AM3/12/21
to cas-...@apereo.org
I've got same problem with this. Problem is that You have to override main templates to able to use fragments. For example to in file layout.html. You have to override to use fragment from nextor

<div th:replace="fragments/nextor/footer :: footer">
<a href="fragments/nextor/footer.html">Footer</a> fragment will go here
</div>

--
- 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.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/9fde0bf8-e0b1-41c0-a03e-f9548bd5fbd8n%40apereo.org.

artur miś

unread,
Mar 12, 2021, 7:07:49 AM3/12/21
to CAS Community, Łukasz Woźniak
Dear Łukasz,:

I have like below  ( /cas/cas7 is  mounted to container to /etc/cas) , you  mensioned  that i have to modify  layout.html   to :     fragments/nextor/footer.html  but
location of my customised templates is :  container-/etc/cas/templates/nextor(host- /cas/cas7/templates/nextor ). And with this setings bellow Cutomised views are not appliled.

ss@zal:/cas/cas7/templates/nextor$ more layout.html
<!DOCTYPE html>

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />

    <title layout:title-pattern="$CONTENT_TITLE - $LAYOUT_TITLE">CAS &#8211; Central Authentication Service</title>

    <!--/* Core CAS CSS */-->
    <link rel="stylesheet" type="text/css" href="../static/css/normalize.css" th:href="@{#{webjars.normalize.css}}" />
    <link rel="stylesheet" type="text/css" href="../static/css/bootstrap-grid.min.css" th:href="@{#{webjars.bootstrap-grid.css}}" />
    <link rel="stylesheet" type="text/css" href="../static/css/material-components-web.min.css" th:href="@{#{webjars.material-components.css}}" />
    <link rel="stylesheet" type="text/css" href="../static/css/mdi-font.css" th:href="@{#{webjars.mdi-font.css}}" />
    <link rel="stylesheet" type="text/css" href="../static/css/cas.css" th:href="@{${#themes.code('cas.standard.css.file')}}"/>

    <link rel="icon" th:href="@{/favicon.ico}" type="image/x-icon"/>
</head>

<body>
<script th:replace="nextor/fragments/scripts" />

<div th:replace="nextor/fragments/header :: header">
    <a href="nextor/fragments/header.html">Header</a> fragment will go here
</div>

<div class="mdc-drawer-scrim"></div>

<div class="mdc-drawer-app-content mdc-top-app-bar--fixed-adjust d-flex justify-content-center" style="padding-top:0;">
    <main role="main" id="main-content" class="container-lg py-4">
        <div layout:fragment="content" id="content">
            CAS content will go here
        </div>
    </main>
</div>

<div th:replace="nextor/fragments/footer :: footer">
    <a href="nextor/fragments/footer.html">Footer</a> fragment will go here
</div>

</body>
</html>


Do i have to move  fragments  for nextor  inside general fragments ? 

artur miś

unread,
Mar 12, 2021, 7:56:50 AM3/12/21
to CAS Community, Łukasz Woźniak

 I think that you wanted to  write :

 <div th:replace="nextor/fragments/footer :: footer">
<a href="nextor/fragmentsfooter.html">Footer</a> fragment will go here
</div>

didn't you ?


But in other side i think cas can't see   folder /cas/cas7/templates/nextor 

ss@zz:/cas/cas7/templates$ ls      ( container : /etc/cas )
casLoginView.html  fragments  nextor.

I have test making changs to file : /cas/cas7/templates/casLoginView.html
from fragments/loginform.html ->  nextor/fragments

 <section id="loginForm"
                class="login-section login-form"
                th:if="${@casThymeleafLoginFormDirector.isLoginFormViewable(#vars)}">
                <div th:replace="nextor/fragments/loginform :: loginform">
                    <a href="nextor/fragments/loginform.html">Login Form goes here</a>
                </div>
            </section>
            <section id="providers" class="login-section login-providers" th:if="${delegatedAuthenticationProviderConfigurations} OR ${wsfedUrls}">
                <div th:replace="nextor/fragments/loginProviders :: loginProviders">
                    <a href="nextor/fragments/loginProviders.html">loginProviders</a>
                </div>
            </section>

            <section id="acceptto" class="login-section login-qr d-xs-none d-md-block" th:if="${accepttoApplicationId}">
                <div th:replace="nextor/fragments/accepttoQRCode :: accepttoQRCode">
                    <a href="nextor/fragments/accepttoQRCode.html">accepttoQRCode</a>
                </div>
            </section>

and  some changes are appiled to default  view, but you know i dont want change dafalut  login page  https://sthsth/cass/login but  i want change views for services.





piątek, 12 marca 2021 o 10:49:39 UTC+1 Łukasz Woźniak napisał(a):

artur miś

unread,
Mar 12, 2021, 11:34:06 AM3/12/21
to CAS Community, artur miś

"By default, Thymeleaf interprets all relative file paths as if they were rooted at the templates directory. If we do not make this change, we will be including the fragments from the default layout (rooted at templates), not our custom layout (rooted at templates/newschool)."


But not work.Probably Above mentioned tutorial is for older version form 6.2.x.  Other possiblity  cas cant reach  templates/nextor when is outside the webapp. I don know. 

Andy Ng

unread,
Mar 16, 2021, 9:37:57 PM3/16/21
to CAS Community, artur...@gmail.com
Hi there,

I have managed to make external customized views works in CAS 6.2.x, I don't have the time to test this out in CAS 6.3 yet but please try this out see if it works:

Instead of putting nextor in:
- /your/external/folder/templates/nextor
You should do it like this:
-  /your/external/folder/templates/themes/nextor

I didn't found this in the official doc, I found this my looking at CAS source code some time ago.

See if this still works in CAS 6.3... If it does not work I have no idea what's wrong as well. Or maybe CAS 6.3 have some new change.

Cheers,
Andy

Frédéric Lohier

unread,
Jul 28, 2021, 8:31:39 AM7/28/21
to CAS Community, Andy Ng, artur...@gmail.com
Hello Andy,

Thank you very much for this! 

It seems that the documentation needs a correction. Specifically, the "Dynamic views" part in the UI customization documentation page (https://apereo.github.io/cas/6.3.x/ux/User-Interface-Customization-Themes.html#themed-views) says : 

"For instance, if the external path for CAS views is /etc/cas/templates, view template files for theme sample may be located /etc/cas/templates/sample/."
 
-Frederic

Reply all
Reply to author
Forward
0 new messages