CAS, config server and bootstrap outside war file

49 views
Skip to first unread message

Matthieu Marc

unread,
Nov 16, 2020, 11:09:54 AM11/16/20
to cas-...@apereo.org
Hi everyone,

I am working on CAS 6.1.5 and I configured a spring configuration server for my spring-boot applications.

The spring config server is working as expected for my CAS instance : I wrote the bootstrap.properties file and put it in the src/main/resources directory before building with gradlew. The war file included the file and the service is starting as expected.

But, I manage my source file with git and I don't want to commit the bootstrap.properties file with content credentials used to connect to the spring config server. With my spring-boot2 application, I do not include this file in the jar file, put the file on my server in a directory called config, and launch the application with the following command :  java -Dloader.path="config" -jar myapp.jar

I tried to do so with CAS, but the bootstrap.properties file is not read as expected.

My question is how to make it working with the bootstrap.properties file outside the jar/war file ? Or are there others options/methods to not include spring config credential in bootstrap.properties commited on the git repository ?

Thanks.


- - - -

CAS Version: 6.1.5
CAS Branch: 6.1.x
CAS Commit Id: ca6c71ae73f2418843a300165115a4c137649680
CAS Build Date/Time: 2020-02-29T00:51:20Z
Spring Boot Version: 2.2.0.RELEASE
Spring Version: 5.2.0.RELEASE
Java Home: /usr/lib/jvm/java-11-openjdk-amd64
Java Vendor: Ubuntu
Java Version: 11.0.9.1

Ray Bon

unread,
Nov 16, 2020, 3:41:40 PM11/16/20
to cas-...@apereo.org
Matthieu,

In our tomcat bin directory, we have a file called setenv.sh with a couple lines like this (among others)

CATALINA_OPTS="$CATALINA_OPTS -Dspring.config.additional-location=/home/uvtomcat/config/bootstrap.yml"
CATALINA_OPTS="$CATALINA_OPTS -Dspring.cloud.config.uri=https://user:pass...@config.local/casconfigserver"
export CATALINA_OPTS

bootstrap.yml (and some other config) gets deployed by jenkins and looks like

spring:
  cloud:
    config:
      username: casuser
      password: Mellon

Ray

Note: do not hard code the username password in setenv.sh, tomcat writes CATALINA_OPTS to log on startup.

On Mon, 2020-11-16 at 17:09 +0100, Matthieu Marc wrote:
Notice: This message was sent from outside the University of Victoria email system. Please be cautious with links and sensitive information.
-- 
Ray Bon
Programmer Analyst
Development Services, University Systems

I respectfully acknowledge that my place of work is located within the ancestral, traditional and unceded territory of the Songhees, Esquimalt and WSÁNEĆ Nations.

Matthieu Marc

unread,
Nov 17, 2020, 5:05:13 AM11/17/20
to cas-...@apereo.org
Thank you Ray,

But unfortunately, it is not working for me. When adding -Dspring.config.additional-location and/or -Dspring.cloud.config.uri, the application will not retrieve the configuration from the config server.

But. I find that using this configuration : spring.cloud.bootstrap.location  work as expected.

My command line is : /usr/lib/jvm/java-11-openjdk-amd64/bin/java  -Dspring.cloud.bootstrap.location=./config/bootstrap.yml -jar cas.war

I will now be able to write a systemd file to launch the application automatically.

Matthieu


--
- 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/e9f4034103d8f280700bfd9a08c1e65fd4c57b24.camel%40uvic.ca.
Reply all
Reply to author
Forward
0 new messages