cas

Can't Define Services in CAS Overlay Template v. 6.4 (Docker)


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

Solution

  • What am I doing wrong?

    Multiple things.