4

Using the cas-overlay-template, I am trying to access the CAS login screen from HTTP(s)://localhost/admin:

https://localhost:8443/cas/login?service=https%3A%2F%2F0.0.0.0%2Fadmin

To do this, I am trying to define services inside /etc/cas/services/services.json:

{
    "@class" : "org.apereo.cas.services.RegexRegisteredService",
    "serviceId" : "^http://.*",
    "name" : "http_services",
    "allowed": true,
    "ssoEnabled": true,
    "anonymousAccess": false,
    "id" : 1,
    "evaluationOrder" : 1
},
{
    "@class" : "org.apereo.cas.services.RegexRegisteredService",
    "serviceId" : "^https://.*",
    "name" : "https_services",
    "allowed": true,
    "ssoEnabled": true,
    "anonymousAccess": false,
    "id" : 2,
    "evaluationOrder" : 2
}

FWIW, I've also tried to define a service file according to the pattern described here.

In /etc/config/cas.properties, I have defined the following:

cas.server.name=https://cas.example.org:8443
cas.server.prefix=${cas.server.name}/cas
cas.service-registry.json.location=classpath:/services
logging.config=file:/etc/cas/config/log4j2.xml

Finally in build.gradle, I have added the support for JSON service registry:

dependencies {
    ...
    implementation "org.apereo.cas:cas-server-support-json-service-registry:${casServerVersion}"
}

No matter what I do, after building and running the Docker image, I always get the same thing:

INFO [org.apereo.cas.services.AbstractServicesManager] - <Loaded [0] service(s) from [JsonServiceRegistry].>

When I go to the URL, I am told

"Application Not Authorized to Use CAS".

What am I doing wrong?

Bonus question: https://cas.example.org:8443 does not work in the URL. Do I need to edit something in the docker container to get this to map onto my local machine?

-- UPDATE --

As was said in the answer, I needed to create a single, named service:

// File: /etc/cas/services/today-12345.json
{
    "@class":"org.apereo.cas.services.RegexRegisteredService",
    "serviceId":"^(https|http|imaps)://.*",
    "name":"today",
    "id" :12345
}

To part 2 of Misagh's answer, based on what I'm seeing in the Dockerfile, the /etc/cas/services directory simply doesn't exist by the time ./gradlew runs, and so the services aren't registered.

If I put in my cas.properties file

cas.service-registry.json.location=/etc/cas/services

I get a stacktrace that includes:

Caused by: java.io.FileNotFoundException: class path resource [etc/cas/services] cannot be resolved to URL because it does not exist

If I /bin/sh into the container, I can see the service inside of the /etc/cas/services directory.

I've been getting around this by simply copying the .json file after the Docker containers have been built

docker cp ~/emu/cas-overlay-template/etc/cas/services/today-12345.json [CONTID]:/tmp/services

(/tmp/services because that's where the console output says it's watching for services)

-- SOLUTION --

The path had to be:

cas.service-registry.json.location=file:/etc/cas/services

2 Answers 2

4

What am I doing wrong?

Multiple things.

  • You have your services in /etc/cas/services/services.json as a single JSON file. That is not correct. You need to have 1 file per 1 app. Consult the documentation for JSON service registry.
  • cas.service-registry.json.location should point to the directory location where such JSON files are found. You need to make sure this location in your Docker setup points or contains your service definitions.
1
  • 1
    Thanks, Misagh. The path had to be in the following format: "cas.service-registry.json.location=file:/etc/cas/services".
    – Ravioli87
    Mar 29, 2021 at 1:10
0

I know I'm a bit late but I think the location /etc/cas/services it is defined in the apereo cas standalone profile. If you define another spring profile it will look for /tmp/services. It happened to me while configuring cas in docker environment and wanting to use a test profile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.