MongoDb Authentication

Verify and authenticate credentials against a MongoDb instance. Support is enabled by including the following dependency in the WAR overlay:

implementation "org.apereo.cas:cas-server-support-mongo:${project.'cas.version'}"
<dependency>
  <groupId>org.apereo.cas</groupId>
  <artifactId>cas-server-support-mongo</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-mongo"
}

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.mongo.password-encoder.encoding-algorithm=
  • The encoding algorithm to use such as 'MD5'. Relevant when the type used is 'DEFAULT' or 'GLIBC_CRYPT'.

  • cas.authn.mongo.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.
    @see PasswordEncoderTypes

  • cas.authn.mongo.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.mongo.client-uri=
  • The connection uri to the mongodb instance. This typically takes on the form of mongodb://user:psw@ds135522.somewhere.com:35522/db. If not specified, will fallback onto other individual settings. If specified, takes over all other settings where applicable.

  • cas.authn.mongo.collection=
  • MongoDb database collection name to fetch and/or create.

  • cas.authn.mongo.database-name=
  • MongoDb database instance name.

  • cas.authn.mongo.host=localhost
  • MongoDb database host for authentication. Multiple host addresses may be defined, separated by comma. If more than one host is defined, it is assumed that each host contains the port as well, if any. Otherwise the configuration may fallback onto the port defined.

  • cas.authn.mongo.password=
  • MongoDb database password for authentication.

  • cas.authn.mongo.port=27017
  • MongoDb database port.

  • cas.authn.mongo.user-id=
  • MongoDb database user for authentication.

    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.mongo.password-encoder.character-encoding=UTF-8
  • The encoding algorithm to use such as 'UTF-8'. Relevant when the type used is 'DEFAULT'.

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

  • cas.authn.mongo.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.mongo.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.mongo.principal-transformation.case-conversion=
  • Indicate whether the principal identifier should be transformed into upper-case, lower-case, etc.NONE:No conversion..LOWERCASE:Lowercase conversion..UPPERCASE:Uppercase conversion..

  • cas.authn.mongo.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.mongo.principal-transformation.prefix=
  • Prefix to add to the principal id prior to authentication.

  • cas.authn.mongo.principal-transformation.suffix=
  • Suffix to add to the principal id prior to authentication.