Strangeen / cas-server-4.2.x-deployment-package

a fast and little required for configuration deployment package for cas server 4.2.7 with basic functions
Apache License 2.0
1 stars 2 forks source link

概述

cas是yale大学的单点登录系统开源项目,在行业中非常流行,功能也非常强大,但由于cas系统非常庞大,系统和文档版本迭代又比较多,造成各种文档和网上的教程都无法完全匹配,初次使用时的学习成本会非常大。所以出于方便后期快速使用的考虑,我对cas4.2.7进行了学习研究,在我能理解的范围内,将工作和学习中接触过的场景纳入cas进行配置,基于方便统一配置的理念,基于cas4.2.7修改了一些配置文件、文件存放路径以及添加了部分功能,并最终打包封装成了一套仅需极简配置就可以部署完成的运行于下述性能情况的系统部署包

性能

  1. 使用普通认证模式,非代理认证模式(Proxy Authentication)

  2. 使用cas协议3.0认证(cas protocol 3.0)

  3. 使用JDBC验证用户信息,如Mysql/Oracle数据库(默认mysql,Oracle需要导入jar包并配置dataSource bean)

该套系统部署包仅使用了cas4.2.7的部分功能,其他功能后续会继续完善,使用过程中任何问题请在cas server4.2.x部署包1.0.0发布留言

Quick Start

将部署包文件下载到本地,放入tomcat的webapp/cas文件夹中,按如下方法做基本配置:

dataSource配置

配置/WEB-INF/cas.properties文件:

cas.jdbc.authn.search.password=password
cas.jdbc.authn.search.user=username
cas.jdbc.authn.search.table=user_account
···
database.driverClass=com.mysql.jdbc.Driver
database.url=jdbc:mysql://127.0.0.1:3306/cas_test
database.user=root
database.password=root

http/https配置

默认已配置为:部署http,部署路径/cas,如现状满足就不需要修改配置了。如果需要部署为https或更改部署路径,查看更多配置 - 3. http/https部署进行配置

基本配置完成,打开浏览器输入localhost/cas就可以登陆cas了


更多配置

1. 登陆验证

2. Attribute传递(Attribute Release) 和 Service注册(Service Registry)

3. http/https部署

4. 单点登出

5. 登陆状态超时(TGT超时)

6. cookie超时(TGC超时)

7. ST验证超时

8. UI界面

9. Logger

10. 登出


附A 注释解释

注释1

官方密码加密验证模式:MD5+官方实现格式算法,格式算法代码在cas-server-core-authentication-4.2.7.jarorg.jasig.cas.authentication.handler类中实现,下面列出代码:

private static String getFormattedText(final byte[] bytes) {
    final StringBuilder buf = new StringBuilder(bytes.length * 2);

    for (int j = 0; j < bytes.length; j++) {
        buf.append(HEX_DIGITS[(bytes[j] >> HEX_RIGHT_SHIFT_COEFFICIENT) & HEX_HIGH_BITS_BITWISE_FLAG]);
        buf.append(HEX_DIGITS[bytes[j] & HEX_HIGH_BITS_BITWISE_FLAG]);
    }
    return buf.toString();
}

附B 配置文件位置配置

1. /WEB-INF/spring-configuration/deployerConfigContext.xml

/WEB-INF/web.xml

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/spring-configuration/*.xml
···

2. /WEB-INF/cas.properties

/WEB-INF/spring-configuration/propertyFileConfigurer.xml

<util:properties id="casProperties" location="classpath:../cas.properties" />

注:除了使用classpath作为相对路径,还可以使用filefile是以tomcat的运行文件catalina.bat(.sh)文件位置为相对路径的,即/bin/目录,后面的配置采用相同的机制

3. /WEB-INF/services/

/WEB-INF/classes/cas.properties

service.registry.config.location=classpath:../services

4. /WEB-INF/classes/log4j2.xml

默认配置为/WEB-INF/classes/log4j2.xml,如需更改需要向JVM运行实例(JVM runtime instance)添加-D参数,仅以Tomcat为例: tomcat_folder/bin/下:

5. /WEB-INF/logs/*.log

/WEB-INF/classes/log4j2.xml

<RollingFile name="file" 
    fileName="../webapps/cas/WEB-INF/logs/cas.log" append="true"
    filePattern="../webapps/cas/WEB-INF/logs/cas-%d{yyyy-MM-dd-HH}-%i.log">
···
<RollingFile name="auditlogfile"     
    fileName="../webapps/cas/WEB-INF/logs/cas_audit.log" append="true" 
    filePattern="../webapps/cas/WEB-INF/logs/cas_audit-%d{yyyy-MM-dd-HH}-%i.log">
···
<RollingFile name="perfFileAppender" 
    fileName="../webapps/cas/WEB-INF/logs/perfStats.log" append="true"
    filePattern="../webapps/cas/WEB-INF/logs/perfStats-%d{yyyy-MM-dd-HH}-%i.log">

6. /WEB-INF/spring-configuration/propertyFileConfigurer.xml

/WEB-INF/spring-configuration/cas-servlet.xml

<import resource="propertyFileConfigurer.xml"/>