• 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 Authentication Handler

January 10, 2025 by Mister PKI Leave a Comment

This article will demonstrate how to configure a specific authentication handler for a given service in the Apereo CAS Identity Provider (IDP). The article assumes the json service registry is used.

CAS supports multiple authentication handlers being configured at once and in my experience follows each handler in the list until a handler is found that finds the given credentials. This is a general statement and should not be taken as fact. To be sure, an order can be specified as in the example below.

You may be in a situation where you have multiple authentication handlers defined in CAS properties but wish to specify in a service which handler to use. This will improve efficiency in your user authentications.

Is it possible to specify that a given service in the json registry use a specific authentication handler defined in CAS properties? Read further to find out.

CAS Properties

For example, we have an authentication handler configured here in cas.groovy properties.

This particular authentication handler uses starttls, encrypted secrets, and the pwdLastSet attribute used for a custom password policy in groovy. Let us know if you would like to see an article published on those features.

cas.authn.ldap["0"].name="handler0"
cas.authn.ldap["0"].order=0
cas.authn.ldap["0"].type="AUTHENTICATED"
cas.authn.ldap["0"].ldapUrl="ldap://ldap-1.example.com:389,ldap://ldap-2.example.com:389"
cas.authn.ldap["0"].baseDn="cn=users,dc=example,dc=com|cn=external,dc=example,dc=com"
cas.authn.ldap["0"].bindDn="cn=ldapmanager,dc=example,dc=com"
cas.authn.ldap["0"].bindCredential="{cas-cipher}abc123"
cas.authn.ldap["0"].searchFilter="(sAMAccountName={user})"
cas.authn.ldap["0"].useStartTls="true"
cas.authn.ldap["0"].trustStore="file:/etc/cas/config/truststore.p12"
cas.authn.ldap["0"].trustStorePassword="changeit"
cas.authn.ldap["0"].trustStoreType="PKCS12"
cas.authn.ldap["0"].principalAttributeList="cn,givenName,sn,mail,samAccountName"
cas.authn.ldap["0"].additionalAttributes="pwdLastSet"
cas.authn.ldap["0"].passwordPolicy.enabled="true"
cas.authn.ldap["0"].passwordPolicy.strategy="GROOVY"
cas.authn.ldap["0"].passwordPolicy.groovy.location="file:/etc/cas/config/groovy/password-policy.groovy"

With this configuration, the authentication handler will execute for every configured service in your registry. If you wish to only have it active for execution when needed, use this property.

cas.authn.ldap["0"].state=STANDBY

Now the authentication handler will only executed when called specifically by a registered service.

JSON Service

In /etc/cas/services, create a new service. Take note of the authenticationPolicy that specifies the name of the authentication handler to use.

{
  "@class": "org.apereo.cas.support.saml.services.SamlRegisteredService",
  "serviceId": "https://service.example.com",
  "name": "example",
  "environments": [
    "java.util.HashSet",
    [
      "prod"
    ]
  ],
  "id": 1,
  "authenticationPolicy": {
    "@class": "org.apereo.cas.services.DefaultRegisteredServiceAuthenticationPolicy",
    "requiredAuthenticationHandlers": [
      "java.util.TreeSet",
      [
        "handler0"
      ]
    ],
    "criteria": {
      "@class": "org.apereo.cas.services.AllowedAuthenticationHandlersRegisteredServiceAuthenticationPolicyCriteria"
    }
  },
  "metadataLocation": "https://service.example.com/metadata",
  "evaluationOrder": 1,
  "requiredNameIdFormat": "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified",
  "usernameAttributeProvider": {
    "@class": "org.apereo.cas.services.PrincipalAttributeRegisteredServiceUsernameProvider",
    "usernameAttribute": "samAccountName"
  },
  "attributeReleasePolicy": {
    "@class": "org.apereo.cas.services.DenyAllAttributeReleasePolicy"
  }
}

Conclusion – Apereo CAS Authentication Handler

This article has demonstrated how to specify a specific authentication handler in a given json service. Let us know in the comments if you have any questions or would like to see more Apereo CAS examples.

Apereo CAS,  Identity Management

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.