cas-server之JDBC Authentication

  • 添加依赖
    <dependency>
      <groupId>org.jasig.cas</groupId>
      <artifactId>cas-server-support-jdbc</artifactId>
      <version>${cas.version}</version>
    </dependency>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.21</version>
    </dependency>
  <!--
    系统已经依赖了c3p0连接池
  -->
  • 配置deployerConfigContext.xml
<!--
<alias name="acceptUsersAuthenticationHandler" alias="primaryAuthenticationHandler" />
-->
<!--数据源-->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="jdbcUrl" value="${cas.database.url}"/>
    <property name="driverClass" value="${cas.database.driverClass}"/>
    <property name="user" value="${cas.database.user}"/>
    <property name="password" value="${cas.database.password}"/>
    <property name="maxPoolSize" value="${cas.database.maxPoolSize}"/>
    <property name="initialPoolSize" value="${cas.database.minPoolSize}"/>
    <property name="minPoolSize" value="${cas.database.initialPoolSize}"/>
    <property name="maxIdleTime" value="${cas.database.maxIdleTime}"/>
</bean>
<!--使用jdbc验证用户信息-->
<alias name="dataSource" alias="queryEncodeDatabaseDataSource"/>
<alias name="queryAndEncodeDatabaseAuthenticationHandler" alias="primaryAuthenticationHandler"/>

  • 配置cas.properties
# MySQL DataSources
cas.database.url=
cas.database.driverClass=
cas.database.user=
cas.database.password=
cas.database.maxPoolSize=
cas.database.minPoolSize=
cas.database.initialPoolSize=
cas.database.maxIdleTime=

## QueryAndEncodeDatabaseAuthenticationHandler实现
#查询用户的sql,返回记录不超过1条,如select id,username,password,phone from user where username = ?
cas.jdbc.authn.query.encode.sql=
#算法名称,如MD5
cas.jdbc.authn.query.encode.alg=
#静态/私盐,与数据库密码盐组合,形成动态盐
cas.jdbc.authn.query.encode.salt.static=
#密码字段名,默认password
cas.jdbc.authn.query.encode.password=
#密码盐字段名,默认salt
cas.jdbc.authn.query.encode.salt=
#密码重复加密次数字段名,默认numIterations
cas.jdbc.authn.query.encode.iterations.field=
#密码重复加密次数,默认0
cas.jdbc.authn.query.encode.iterations=

##QueryDatabaseAuthenticationHandler实现
#查询用户密码,只能返回密码值,如select password from user where username = ?
cas.jdbc.authn.query.sql=

##SearchModeSearchDatabaseAuthenticationHandler实现
##该实现传入username和password,判断返回结果数,一般不建议使用
#密码字段
cas.jdbc.authn.search.password=
#用户名字段
cas.jdbc.authn.search.user=
#用户表名
cas.jdbc.authn.search.table=

#上面三种实现取一只就行,建议第一种
    原文作者:a乐乐_1234
    原文地址: https://www.jianshu.com/p/67954be19d94
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞