Database Authentication
Database authentication is enabled by including the following dependencies in the WAR overlay:
1
2
3
4
5
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-jdbc</artifactId>
<version>${cas.version}</version>
</dependency>
1
implementation "org.apereo.cas:cas-server-support-jdbc:${project.'cas.version'}"
1
2
3
4
5
6
7
8
9
dependencyManagement {
imports {
mavenBom "org.apereo.cas:cas-server-support-bom:${project.'cas.version'}"
}
}
dependencies {
implementation "org.apereo.cas:cas-server-support-jdbc"
}
1
2
3
4
5
6
7
8
9
10
dependencies {
/*
The following platform references should be included automatically and are listed here for reference only.
implementation enforcedPlatform("org.apereo.cas:cas-server-support-bom:${project.'cas.version'}")
implementation platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)
*/
implementation "org.apereo.cas:cas-server-support-jdbc"
}
To learn how to configure database drivers, please see this guide.
Configuration
Query Database Authentication
Authenticates a user by comparing the user password (which can be encoded with a password encoder) against the password on record determined by a configurable database query.
The following settings and properties are available from the CAS configuration catalog:
cas.authn.jdbc.query[0].password-encoder.encoding-algorithm=
The encoding algorithm to use such as
|
cas.authn.jdbc.query[0].password-encoder.type=NONE
Define the password encoder type to use.
Type may be specified as blank or
|
cas.authn.jdbc.query[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. In the event the configured resource is a Groovy script, specially if the script set to reload on changes, you may need to adjust the total number ofinotify instances.
On Linux, you may need to add the following line to /etc/sysctl.conf :
fs.inotify.max_user_instances = 256 .
You can check the current value via cat /proc/sys/fs/inotify/max_user_instances .
|
cas.authn.jdbc.query[0].driver-class=org.hsqldb.jdbcDriver
The JDBC driver used to connect to the database.
|
cas.authn.jdbc.query[0].field-password=
Password field/column name to retrieve.
|
cas.authn.jdbc.query[0].password=EMPTY
The database connection password.
|
cas.authn.jdbc.query[0].sql=
SQL query to execute. Example:
|
cas.authn.jdbc.query[0].url=jdbc:hsqldb:mem:cas-hsql-database
The database connection URL. This setting supports the Spring Expression Language.
|
cas.authn.jdbc.query[0].user=sa
The database user. The database user must have sufficient permissions to be able to handle schema changes and updates, when needed.
|
cas.authn.jdbc.query[0].password-encoder.character-encoding=UTF-8
The encoding algorithm to use such as 'UTF-8'.
Relevant when the type used is
|
cas.authn.jdbc.query[0].password-encoder.hash-length=16
When used by
|
cas.authn.jdbc.query[0].password-encoder.secret=
Secret to use with
|
cas.authn.jdbc.query[0].password-encoder.strength=16
Strength or number of iterations to use for password hashing.
Usually relevant when dealing with
|
cas.authn.jdbc.query[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.jdbc.query[0].principal-transformation.case-conversion=NONE
Indicate whether the principal identifier should be transformed into upper-case, lower-case, etc. Available values are as follows:
|
cas.authn.jdbc.query[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.jdbc.query[0].principal-transformation.prefix=
Prefix to add to the principal id prior to authentication.
|
cas.authn.jdbc.query[0].principal-transformation.suffix=
Suffix to add to the principal id prior to authentication.
|
cas.authn.jdbc.query[0].pool.keep-alive-time=0
This property controls the keepalive interval for a connection in the pool. An in-use connection will never be tested by the keepalive thread, only when it is idle will it be tested. Default is zero, which disables this feature. This settings supports the
|
cas.authn.jdbc.query[0].pool.max-size=18
Controls the maximum number of connections to keep in the pool, including both idle and in-use connections.
|
cas.authn.jdbc.query[0].pool.max-wait=PT2S
Sets the maximum time in seconds that this data source will wait while attempting to connect to a database. A value of zero specifies that the timeout is the default system timeout if there is one; otherwise, it specifies that there is no timeout. This settings supports the
|
cas.authn.jdbc.query[0].pool.maximum-lifetime=PT10M
This property controls the maximum lifetime of a connection in the pool. When a connection reaches this timeout, even if recently used, it will be retired from the pool. An in-use connection will never be retired, only when it is idle will it be removed. This settings supports the
|
cas.authn.jdbc.query[0].pool.min-size=6
Controls the minimum size that the pool is allowed to reach, including both idle and in-use connections.
|
cas.authn.jdbc.query[0].pool.name=
Set the name of the connection pool. This is primarily used for the MBean to uniquely identify the pool configuration.
|
cas.authn.jdbc.query[0].pool.suspension=
Whether or not pool suspension is allowed. There is a performance impact when pool suspension is enabled. Unless you need it (for a redundancy system for example) do not enable it.
|
cas.authn.jdbc.query[0].pool.timeout-millis=1_000L
The maximum number of milliseconds that the pool will wait for a connection to be validated as alive.
|