• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

Mister PKI

SSL Certificates * SSL Tools * Certificate Decoder

  • PKI Training
  • OpenSSL
  • Keytool
  • PKI Tools
    • Apereo CAS
    • SAML
    • OpenID Connect
  • Get expert help

Apereo CAS Access Strategy

January 23, 2025 by Mister PKI Leave a Comment

This article will demonstrate how to create an Apereo CAS Access Strategy for customized authorization rules to specific registered services.

The examples below assume you already have json registered services configured. The accessStrategy will be included in your json service.

Access strategies may be based on:

  • Attributes
  • Custom groovy scripts
  • Grouper
  • HTTP
  • REST
  • OpenFGA
  • Permit.io
  • Open Policy Agent
  • and more…

Access Strategy – Attribute based

This example used the DefaultRegisteredServiceAccessStrategy and rejects authorization if the user has a specific attribute.

  • enabled – This service is enabled. If you wish to disable a service altogether without deleting it, change this to false.
  • ssoEnabled – When set to false, this will require the service to be logged in to each time it is accessed. When set to false, other services will still work with Single Sign On (SSO) even if this service was logged in to first. If a registered saml service, this is effectively the same thing as renew=true in a CAS service.
  • unauthorizedRedirectUrl – The url to redirect users to if they fail authorization.
  • rejectedAttributes – In this case, users with the affiliation attribute set to student will be denied access.
"accessStrategy": {
    "@class": "org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy",
    "enabled": true,
    "ssoEnabled": false,
    "unauthorizedRedirectUrl": "https://example.com",
    "rejectedAttributes": {
      "@class": "java.util.HashMap",
      "affiliation": [
        "java.util.HashSet",
        [
          "student"
        ]
      ]
    }
  }

Access Strategy – IP Based

This example uses the HttpRequestRegisteredServiceAccessStrategy and requires the user to be coming from a specific IP address range based on the given regex.

  • ipAddress – regex of required IP addresses
  • userAgent – regex of required user agents
  • headers – regex of required headers
"accessStrategy" : {
    "@class" : "org.apereo.cas.services.HttpRequestRegisteredServiceAccessStrategy",
    "ipAddress" : "10.\\d\\d\\d.\\d\\d\\d.10",
    "userAgent": "Chrome.+",
    "headers":{
      "@class": "java.util.TreeMap",
      "Header1": "Value.+Pattern"
    }
  }

Multiple Access Strategies

This example uses the ChainingRegisteredServiceAccessStrategy and can chain authorization requirements based on an operator of AND or OR.

"accessStrategy": {
    "@class": "org.apereo.cas.services.ChainingRegisteredServiceAccessStrategy",
    "strategies": [
      "java.util.ArrayList",
      [
        {
          "@class": "org.apereo.cas.services.HttpRequestRegisteredServiceAccessStrategy",
          "ipAddress" : "10.\\d\\d\\d.\\d\\d\\d.10",
          "userAgent": "Chrome.+",
          "headers":{
            "@class": "java.util.TreeMap",
            "Header1": "Value.+Pattern"
          }
        },
        {
         "@class": "org.apereo.cas.services.DefaultRegisteredServiceAccessStrategy",
         "enabled": true,
         "ssoEnabled": false,
         "unauthorizedRedirectUrl": "https://example.com",
         "rejectedAttributes": {
           "@class": "java.util.HashMap",
           "affiliation": [
             "java.util.HashSet",
             [
               "student"
             ]
           ]
         }
        }
      ]
    ],
    "operator": "AND"
  }

Conclusion – Apereo CAS Access Strategy

This article has demonstrated how to configure a custom access strategy in Apereo CAS. Let us know in the comments if you would like to see more advanced examples of access strategies and how to chain them. If you found this article helpful, read more of our content on Apereo CAS.

Apereo CAS,  Identity Management,  saml

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Popular Posts

PKCS12

openssl s_client

Keytool

Keytool list

ECDSA vs RSA

OpenSSL

PKCS7

Certificate Decoder

PKI for DevOps Engineers – Free Training Series

PKI for DevOps Training Hub

Lesson 1 – How TLS and PKI Work

Lesson 2 – Understanding X.509 Certificates

Lesson 3 – Certificate Chains Explained

Lesson 4 – Debug TLS with OpenSSL

Lesson 5 – Verify Certificate Chains

Lesson 6 – Creating CSRs with OpenSSL

Lesson 7 – Working with PKCS12 Certificates

Lesson 8 – Java Keystores and keytool

Lesson 9 – Certificate Expiration Monitoring

Lesson 10 – Automating Certificate Renewal

Lesson 11 – Common TLS Errors

Lesson 12 – PKI Architecture for DevOps

Recent Posts

  • Apache mod_auth_cas: Protect Web Applications with Apereo CAS and Docker
  • Apache mod_auth_mellon: Configure SAML SSO & Docker
  • Configure OpenID Connect (OIDC) in Apereo CAS 7.3 and 8
  • Certificate Ownership Is an Operating Model Problem, Not a Tooling Problem
  • OpenSSL dgst: Create Checksums and Verify Digital Signatures

Footer

  • Twitter
  • YouTube
Mister PKI

Practical security engineering for the systems that establish trust.

Learn OpenSSL Keytool Free training
Work together PKI consulting CAS consulting Sponsored contributions
Site About Support Mister PKI Cookie policy Search
© 2026 Mister PKI Secure systems. Clear guidance.