[CAS 6.1.X] custom cas.properties not working for JSON services

76 views
Skip to first unread message

The Jej

unread,
Jan 31, 2019, 1:01:49 PM1/31/19
to CAS Community
Hello everyone, 

I've been using CAS 3.5.2 for quite a long time and I want to upgrade to a newer version.
So I've been following the getting started guide here: https://apereo.github.io/2019/01/07/cas61-gettingstarted-overlay/

I'm using: intellij (latest version) on windows 10.

Here is what I've done: 

2. I've generated a thekeystore file using keytool and added the extracted .crt to my jvm security file.

 -> at this stage, when I'm using: gradlew.bat build run I' ve got an error saying that CAS cannot find the etc/cas/thekeystore file even if the file is correctly present in the generated cas.war

so I've created an src/main/resources/application-standalone.properties witch contains: 

server.ssl.key-store=classpath:/etc/cas/thekeystore



With this the run command launch correctly and I'm able to see the default login page at: https://localhost:8443/cas/login

3. 
I add this line to build.gradle : compile "org.apereo.cas:cas-server-support-json-service-registry:${casServerVersion}"

dependencies {
   
compile "org.apereo.cas:cas-server-webapp${project.appServer}:${casServerVersion}"
    // Other CAS dependencies/modules may be listed here...
    compile "org.apereo.cas:cas-server-support-json-service-registry:${casServerVersion}"
}



I'm trying to add a json registry service to add my services recognized by cas. 
I create the file: src/main/resources/etc/cas/config/cas.properties containing:

cas.server.name=https://localhost:8443
cas
.server.prefix=${cas.server.name}/cas
logging
.config=file:/etc/cas/config/log4j2.xml


cas
.serviceRegistry.initFromJson=false
cas
.serviceRegistry.json.location=file:/etc/cas/services

4. I've created a file in src/main/resources/etc/cas/services/
Name: testId-1.json containing:

{
 
"@class" : "org.apereo.cas.services.RegexRegisteredService",
  "serviceId" : "http://localhost/.*",
  "name" : "testId",
  "id" : 1,
  "accessStrategy" : {
   
"@class" :
    "org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy",
    "enabled" : true,
    "ssoEnabled" : true
  }
}

5. I'm running : gradlew.bat build run

CAS launch correctly but JSON service is not loaded, I'm still getting this in logs:

2019-01-31 18:53:15,046 WARN [org.apereo.cas.config.CasCoreServicesConfiguration] - <Runtime memory is used as the persistence storage for retrieving and persisting service definitions. Changes that are made to service definitions during runtime WILL be LOST when t
he CAS server
is restarted. Ideally for production, you should choose a storage option (JSON, JDBC, MongoDb, etc) to track service definitions.>
2019-01-31 18:53:15,055 INFO [org.apereo.cas.services.AbstractServicesManager] - <Loaded [0] service(s) from [InMemoryServiceRegistry].>


I've passed some hours to try to figure it out, I'd tried a lot of things describe in various similar pb threads:

https://groups.google.com/a/apereo.org/forum/#!topic/cas-user/jJ8OOyoQoBw
https://groups.google.com/forum/#!topic/jasig-cas-user/R0H3nlynQ1k

I've added a bootstrap.properties in /src/main/resources with defaut file and changed: 

spring.cloud.config.server.native.searchLocations=file:/etc/cas/config

But nothing changed.

I also tried to launch with : gradlew.bat build bootRun but it fails with an too long filename error (it seems to be windows related)

Can someone help me ? I have no more ideas at this stage :)

thanks


Ray Bon

unread,
Jan 31, 2019, 3:08:21 PM1/31/19
to cas-...@apereo.org
Have a look at build.cmd. It is a wrapper around gradlew. One of the capabilities is copying etc/cas/*.
After you start CAS, have a look in /etc/cas/services (not sure where that is on Windows) to be sure that your service.json is there.

Ray
-- 
Ray Bon
Programmer analyst
Development Services, University Systems
2507218831 | CLE 019 | rb...@uvic.ca

Andy Ng

unread,
Jan 31, 2019, 8:20:46 PM1/31/19
to CAS Community
Hello,

The problem might be this `src/main/resources/etc/cas/config/cas.properties`

You need to copy the /etc/cas/config/cas.properties to root, in your case because you are using Windows, that means "C:/etc/cas/cas.properties"

if you do not want to put things outside of your directory, then maybe you can use `application.yml` , then you put your properties inside `src/main/resources/application.yml`

See if the above helps.

Cheers!
- Andy

The Jej

unread,
Feb 1, 2019, 4:50:14 AM2/1/19
to CAS Community
Hi Andy, 

Thank you so much ! It finally works
I would never tought to put files outside of my project dir.

I've spend so much time struggling with this, I can finally continue !

Have a nice day ! 

cheers

Andy Ng

unread,
Feb 1, 2019, 4:58:43 AM2/1/19
to CAS Community
Glad it helps! - Andy
Reply all
Reply to author
Forward
0 new messages