Jump to content

User:JBond (WMF)/cas notes

From Wikitech

Testing changes

In order to test the cas-overlay-templates you first need to configure a local ldap docker service and update the cas configuration. The following instructions should get you to this point (tested on ubuntu 19)

We should Add a docker image to do all this!

$ sudo apt-get install docker.io git default-jre default-jdk memcached default-mysql-server
# create a mysql database for cas 
$ git clone ssh://gerrit.wikimedia.org:29418/operations/software/cas-overlay-template
$ cd cas-overlay-template/docker/ldap/
$ sudo docker build --tag="cas/ldap" .
$ sudo docker run -d -p 10389:389 --name="ldap-server" cas/ldap
$ cd ../../
$ sudo mkdir -p /etc/cas/{config,services}
$ sudo cp etc/cas/config/cas.properties.ldap  /etc/cas/config/cas.properties
$ sudo cp etc/cas/config/log4j2.xml /etc/cas/config/
$ sudo cp etc/cas/predict.groovy /etc/cas/
$ sudo cp etc/cas/thekeystore /etc/cas/
$ sudo ./gradlew run

Changing templates

In order to change the html of the various pages you need to update the files under src/main/resources/. this directory has the following files and subdirs

  • cas_common_messages.properties - you can use this file to update the location to styles and javascript files
  • message.properties - english language messages
  • message_XX.properties - locals language messages for XX
  • templates - this directory contains the htmls templates for all the views we use
  • templates/fragments - this directory contains common sippits of html which are use by the template files above
  • templates/error - this directory contains the HTML for all the error pages used by CAS

Missing template files

It is possible that the template or fragment you need is not already included in the cas-overlay-template folder. If this is the case you will first need to unpack it from the war file. In order to unpack the war/jar files we first need to ensure we have build of cas which should exist in build/libs/cas.war. If this doesn't already exist then you can create it by running ./gradlew build. to unpack the files use the following

$ mkdir ~/tmp
$ cd ~/tmp
$ jar xf ~/cas-overlay-template/build/libs/cas.war
$ cd WEB-INF/lib/
$ jar xf cas-server-webapp-resources-6.1.3.jar

Once you have unpacked the jar's all templates will be available under ~/tmp/WEB-INF/lib/templates/. To add a template to the cas-overlay repo simply copy it into place e.g.

$ cp ~/tmp/WEB-INF/lib/templates/casRadiusLoginView.html ~/cas-overlay-template/src/main/resources/templates/

Adding new libraries

The other common change which you may need to perform in the cas-overlay-template repo is to add support for a new library. To do this you you simply need to add the library to dependencies object in build.gradle e.g.

diff --git a/build.gradle b/build.gradle
index 129c16a..2904de4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -51,6 +51,7 @@ dependencies {
      compile "org.apereo.cas:cas-server-support-u2f:${project.'cas.version'}"
      // compile "org.apereo.cas:cas-server-support-memcached-ticket-registry:${project.'cas.version'}"
      // compile "org.apereo.cas:cas-server-support-memcached-spy:${project.'cas.version'}"
+     compile "org.apereo.cas:cas-server-support-memcached-spy:${project.'cas.version'}"
      compile "org.apereo.cas:cas-server-support-metrics:${project.'cas.version'}"
     // Other CAS dependencies/modules may be listed here...
     // compile "org.apereo.cas:cas-server-support-json-service-registry:${casServerVersion}"