LDAP Authentication

LDAP integration is enabled by including the following dependency in the overlay:

implementation "org.apereo.cas:cas-server-support-ldap:${project.'cas.version'}"
<dependency>
  <groupId>org.apereo.cas</groupId>
  <artifactId>cas-server-support-ldap</artifactId>
  <version>${cas.version}</version>
</dependency>
dependencyManagement {
  imports {
    mavenBom "org.apereo.cas:cas-server-support-bom:${project.'cas.version'}"
  }
}

dependencies {  
  implementation "org.apereo.cas:cas-server-support-ldap"
}

Configuration

CAS authenticates a username/password against an LDAP directory such as Active Directory or OpenLDAP. There are numerous directory architectures and we provide configuration for four common cases.

Note that CAS will automatically create the appropriate components internally based on the settings specified below. If you wish to authenticate against more than one LDAP server, increment the index and specify the settings for the next LDAP server.

Note: Attributes retrieved as part of LDAP authentication are merged with all attributes retrieved from other attribute repository sources, if any. Attributes retrieved directly as part of LDAP authentication trump all other attributes.

The following settings and properties are available from the CAS configuration catalog:

The configuration settings listed below are tagged as Required in the CAS configuration metadata. This flag indicates that the presence of the setting is not strictly necessary in the end-user CAS configuration, because a default value may be assigned or the feature in question may not be immediately intended for use. You may want to own the setting and update it assigned value, assuming the intended feature controlled by the setting is utilized.

  • cas.authn.ldap[0].password-encoder.encoding-algorithm=
  • The encoding algorithm to use such as 'MD5'. Relevant when the type used is 'DEFAULT' or 'GLIBC_CRYPT'.

  • cas.authn.ldap[0].password-encoder.type=NONE
  • Define the password encoder type to use. Type may be specified as blank or 'NONE' to disable password encoding. It may also refer to a fully-qualified class name that implements the Spring Security's PasswordEncoder interface if you wish you define your own encoder. The following types may be used:

    • NONE: No password encoding (i.e. plain-text) takes place.
    • DEFAULT: Use the DefaultPasswordEncoder of CAS. For message-digest algorithms via #getCharacterEncoding() and #getCharacterEncoding().
    • BCRYPT: Use the BCryptPasswordEncoder based on the strength provided and an optional secret.
    • SCRYPT: Use the SCryptPasswordEncoder.
    • PBKDF2: Use the Pbkdf2PasswordEncoder based on the strength provided and an optional secret.
    • STANDARD: Use the StandardPasswordEncoder based on the secret provided.
    • SSHA: Use the LdapShaPasswordEncoder supports Ldap SHA and SSHA (salted-SHA). The values are base-64 encoded and have the label SHA</code> (or SSHA</code>) prepended to the encoded hash.
    • GLIBC_CRYPT: Use the GlibcCryptPasswordEncoder based on the encoding-algorithm, strength provided and an optional secret.
    • org.example.MyEncoder: An implementation of PasswordEncoder of your own choosing.
    • file:///path/to/script.groovy: Path to a Groovy script charged with handling password encoding operations.

  • cas.authn.ldap[0].password-policy.groovy.location=
  • The location of the resource. Resources can be URLS, or files found either on the classpath or outside somewhere in the file system.

  • cas.authn.ldap[0].principal-transformation.groovy.location=
  • The location of the resource. Resources can be URLS, or files found either on the classpath or outside somewhere in the file system.

  • cas.authn.ldap[0].base-dn=
  • Base DN to use. There may be scenarios where different parts of a single LDAP tree could be considered as base-dns. Rather than duplicating the LDAP configuration block for each individual base-dn, each entry can be specified and joined together using a special delimiter character. The user DN is retrieved using the combination of all base-dn and DN resolvers in the order defined. DN resolution should fail if multiple DNs are found. Otherwise the first DN found is returned. Usual syntax is: subtreeA,dc=example,dc=net|subtreeC,dc=example,dc=net.

  • cas.authn.ldap[0].bind-credential=
  • The bind credential to use when connecting to LDAP.

  • cas.authn.ldap[0].bind-dn=
  • The bind DN to use when connecting to LDAP. LDAP connection configuration injected into the LDAP connection pool can be initialized with the following parameters:

    • bindDn/bindCredential provided - Use the provided credentials to bind when initializing connections.
    • bindDn/bindCredential set to * - Use a fast-bind strategy to initialize the pool.
    • bindDn/bindCredential set to blank - Skip connection initializing; perform operations anonymously.
    • SASL mechanism provided - Use the given SASL mechanism to bind when initializing connections.

  • cas.authn.ldap[0].ldap-url=
  • The LDAP url to the server. More than one may be specified, separated by space and/or comma.

  • cas.authn.ldap[0].search-filter=
  • User filter to use for searching. Syntax is cn=user or cn=0. You may also provide an external groovy script in the syntax of file:/path/to/GroovyScript.groovy to fully build the final filter template dynamically.

  • cas.authn.ldap[0].type=
  • The authentication type.

    • AD - Users authenticate with sAMAccountName.
    • AUTHENTICATED - Manager bind/search type of authentication. If principalAttributePassword</code> is empty then a user simple bind is done to validate credentials. Otherwise the given attribute is compared with the given rincipalAttributePassword using the SHA encrypted value of it.
    • ANONYMOUS: Similar semantics as AUTHENTICATED except no bindDn and bindCredential may be specified to initialize the connection. If principalAttributePassword is empty then a user simple bind is done to validate credentials. Otherwise the given attribute is compared with the given principalAttributePassword using the SHA encrypted value of it.
    • DIRECT: Direct Bind - Compute user DN from format string and perform simple bind. This is relevant when no search is required to compute the DN needed for a bind operation. Use cases for this type are: 1) All users are under a single branch in the directory, e.g. ou=Users,dc=example,dc=org. 2) The username provided on the CAS login form is part of the DN, e.g. uid=%s,ou=Users,dc=example,dc=org.
    Available values: AD:Active Directory. AUTHENTICATED:Authenticated Search. DIRECT:Direct Bind. ANONYMOUS:Anonymous Search.

    The configuration settings listed below are tagged as Optional in the CAS configuration metadata. This flag indicates that the presence of the setting is not immediately necessary in the end-user CAS configuration, because a default value is assigned or the activation of the feature is not conditionally controlled by the setting value.

  • cas.authn.ldap=
  • Collection of settings related to LDAP authentication. These settings are required to be indexed (i.e. ldap[0].xyz).

  • cas.authn.ldap[0].password-encoder.character-encoding=UTF-8
  • The encoding algorithm to use such as 'UTF-8'. Relevant when the type used is 'DEFAULT'.

  • cas.authn.ldap[0].password-encoder.secret=
  • Secret to use with STANDARD, PBKDF2, BCRYPT, GLIBC_CRYPT password encoders. Secret usually is an optional setting.

  • cas.authn.ldap[0].password-encoder.strength=16
  • Strength or number of iterations to use for password hashing. Usually relevant when dealing with PBKDF2 or BCRYPT encoders. Used by GLIBC_CRYPT encoders as well.

  • cas.authn.ldap[0].principal-transformation.blocking-pattern=
  • A regular expression that will be used against the username to match for blocking/forbidden values. If a match is found, an exception will be thrown and principal transformation will fail.

  • cas.authn.ldap[0].principal-transformation.case-conversion=
  • Indicate whether the principal identifier should be transformed into upper-case, lower-case, etc. Available values: NONE:No conversion. LOWERCASE:Lowercase conversion. UPPERCASE:Uppercase conversion.

  • cas.authn.ldap[0].principal-transformation.pattern=
  • A regular expression that will be used against the provided username for username extractions. On a successful match, the first matched group in the pattern will be used as the extracted username.

  • cas.authn.ldap[0].principal-transformation.prefix=
  • Prefix to add to the principal id prior to authentication.

  • cas.authn.ldap[0].principal-transformation.suffix=
  • Suffix to add to the principal id prior to authentication.