The CAS Demo introduced in the previous blog. the user name and password on the logon interface did not pass the database query authentication. This blog introduces how to use xml configuration to query and authenticate CAS logon databases. Required database sso_cas, database table: tb_user, table fields: Id, username, password; database query authentication (Pass
The CAS Demo introduced in the previous blog. the user name and password on the logon interface did not pass the database query authentication. This blog introduces how to use xml configuration to query and authenticate CAS logon databases. Required database sso _ cas, database table: tb_user, table fields: Id, username, password; database query authentication (Pass
The CAS Demo introduced in the previous blog. the user name and password on the logon interface did not pass the database query authentication. This blog introduces how to use xml configuration to query and authenticate CAS logon databases.
Required database sso_cas, table in the database: tb_user, table fields: Id, username, password;
Database Query authentication (PassXmlConfiguration)
1, ModifyCasServer Configuration
Modify the webapps/cas/WEB_INF/deployerConfigContext. xml file in tomcat as follows:
To:
Add datasource bean definition:
< p><>
Class = "org. springframework. jdbc. datasource. DriverManagerDataSource">
Note:
1. QueryDatabaseAuthenticationHandler is the query interface provided by cas-server-support-jdbc. One of them is to configure an SQL statement to check the password and match it;
2. SQL statement: select password from tb_user whereusername =? Query the password field in Table tb_user Based on username. CAS matches the password entered by the user;
Note: multiple databases can be configured.
If you need to configure multiple databases, you can configure multiple QueryDatabaseAuthenticationHandler and multiple datasource
Assume that there is a user in a_user: auser, B _user has a user buser, so that no matter which user you use to log on, CAS will first check a_user. If the user name and password are correct, it will pass, if the verification fails in a_user, CAS will check B _user again. If the username and password are correct, the verification is successful.
Add relatedJarPackage
You need to add two packages under the lib of the web Project: cas-server-support-jdbc-x.x.x.jar and mysql-connector-java-x.x.x-bin.jar (the specific version number depends on the situation)
After the configuration is as follows, go to the CAS logon page. the user name and password must be authenticated by querying the database. Enter the User Name admin and password 123 to log on successfully. If you enter the User Name admin, the admin password cannot be successfully logged on.