Good morning,
I am at a total loss here about how to get CAS services to load from (and to) MongoDB. Following the instructions on
David Curry's site (very well written, by the way), I have the mongodb server running and replicating across 3 servers. I am also able to successfully auto-initialize the database with the JSON files. I verify this by opening mongodb and searching the collection "casServiceRegistry."
CAS version 5.3.14, by the way.
When I start the tomcat server and watch the debug logs, I see that CAS is loading the entry from the database:
- snippet -
2019-11-13 16:24:22,706 DEBUG [org.apereo.cas.services.AbstractServicesManager] - <Loading services from [org.apereo.cas.services.ChainingServiceRegistry@3971e14f]>
2019-11-13 16:24:22,728 DEBUG [org.apereo.cas.services.AbstractServicesManager] - <Adding registered service [http(|s)://cas(|.*).messiah.edu(|.*)/cas-management(|/.*)]>
2019-11-13 16:24:22,729 INFO [org.apereo.cas.services.AbstractServicesManager] - <Loaded [1] service(s) from [MongoDbServiceRegistry].>
Here is where it gets weird: when I load the management app, I see one service entry that does NOT match the one loaded on startup. I should also note that I have the ticket registry replicated on the same MongoDB server and it works perfectly.
That's the short story, here are the details (these settings match on all 3 servers "cas-ha01, cas-ha02, cas-ha03":
-- cas.properties: --
cas.server.name=https://cas-ha.messiah.edu
cas.server.prefix=${cas.server.name}/cas
cas.view.templatePrefixes[0]=file:///etc/cas/templates
cas.logout.followServiceRedirects=true
logging.config=file:/etc/cas/config/log4j2.xml
mongo.db=casdb
mongo.rs=rs0
mongo.opts=&ssl=true
mongo.creds=mongocas:**********
mongo.hosts=cas-ha01.messiah.edu,cas-ha02.messiah.edu,cas-ha03.messiah.edu
# The connection string, assembled
mongo.uri=mongodb://${mongo.creds}@${mongo.hosts}/${mongo.db}?replicaSet=${mongo.rs}${mongo.opts}
### Remove default/local users (must be left blank) ###
cas.authn.accept.users=
### Service Registry Setup ###
#cas.serviceRegistry.json.location=file:/etc/cas/services
#cas.serviceRegistry.initFromJson=true
cas.serviceRegistry.mongo.databaseName=${mongo.db}
cas.serviceRegistry.mongo.clientUri=${mongo.uri}
cas.serviceRegistry.mongo.collection=casServiceRegistry
cas.serviceRegistry.mongo.replicaSet=${mongo.rs}
cas.serviceRegistry.mongo.sslEnabled=true
cas.ticket.registry.mongo.clientUri=${mongo.uri}
-- management.properties: --
-- pom.xml (cas server, dependencies): --
...
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-webapp${app.server}</artifactId>
<version>${cas.version}</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-ldap</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-ldap-core</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-webapp-config-security</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-interrupt-core</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-interrupt-api</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-interrupt-webflow</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-rest</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-gauth</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-jdbc-drivers</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-gauth-jpa</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-trusted-mfa</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-trusted-mfa-jdbc</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-mongo-ticket-registry</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-mongo-service-registry</artifactId>
<version>${cas.version}</version>
</dependency>
...
-- pom.xml (management app, dependencies): --
...
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-management-webapp</artifactId>
<version>${cas-mgmt.version}</version>
<type>war</type>
</dependency>
...
When I load the Service Management app, here is the service that appears:
But the one that is in the MongoDB table (which I imported from the initFromJson) is:
http(|s)://cas(|.*).messiah.edu(|.*)/cas-management(|/.*)
If I try to create a new service entry, it does not appear in the MongoDB, and I cannot delete the existing one. In fact, I do not know how that one is even getting into the management app (that's what is really driving me nuts, since I have deleted all service json files)!!
If anyone can help me out, I woudl certainly apprecite it.