cas用户验证 postgresql 数据库连接方式
cas 数据库验证用户模式,网上几乎都是统一的mysql模式,其实postgresql也差不多,不多说,上干货。
首先是在编译war包前,在pom文件增加一下几个节点即可。
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-webapp${app.server}</artifactId>
<version>${cas.version}</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apereo.cas</groupId>
<artifactId>cas-server-support-jdbc</artifactId>
<version>${cas.version}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.1.1</version>
</dependency>
这其实就是postgresql数据库驱动包打进去。打包生成war包后,同上一个文章一样,放tomcat下解压,然后再修改 application.properties
这个application.properties文件修改简单,把原来的 cas.authn.accept.users=admin::admin 注释,增加下面一些内容
cas.authn.jdbc.query[0].sql=select * from system_user WHERE username=? cas.authn.jdbc.query[0].url=jdbc:postgresql://10.212.170.186:5432/afptdb4 cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.PostgreSQLDialect cas.authn.jdbc.query[0].user=postgres cas.authn.jdbc.query[0].password=#@!_9987AbcCE~ cas.authn.jdbc.query[0].driverClass=org.postgresql.Driver cas.authn.jdbc.query[0].fieldPassword=password cas.authn.jdbc.query[0].passwordEncoder.type=DEFAULT cas.authn.jdbc.query[0].passwordEncoder.characterEncoding=UTF-8 cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm=MD5
上面这些内容相信程序员都能看懂。
最后一句 cas.authn.jdbc.query[0].passwordEncoder.encodingAlgorithm=MD5 意思是密码 md5 方式加密
