本次方案基于通用CAS单点登录协议,支持所有B/S架构的商业/自研档案管理软件,落地前请准备好以下环境:
sudo apt update && sudo apt install openjdk-11-jdk -yyum install java-11-openjdk-devel -y按顺序操作,不要跳过任何步骤:
cas.war,放入Tomcat根目录下的webapps文件夹./bin/startup.sh,Windows双击bin/startup.bat,等待Tomcat自动解压cas.war生成工程目录webapps/cas/WEB-INF/classes/application.properties,清空原有内容,复制粘贴以下完整配置,替换你自己的域名即可:
```
CAS服务基础配置
cas.server.name=https://cas.你的企业域名.com:8443
cas.server.prefix=${cas.server.name}/cas
服务注册配置
cas.serviceRegistry.initFromJson=true
cas.serviceRegistry.json.location=file:/etc/cas/services/
内置测试用户名密码,后续可对接企业LDAP/AD用户库
cas.authn.accept.enabled=true
cas.authn.accept.users=casadmin|cas123456
关闭无用功能,加快启动速度
cas.monitor.endpoints.enabled=false
management.endpoints.enabled-by-default=false
```
/etc/cas/services,在目录下新建授权文件ArchiveSystem-10000.json,复制以下内容,替换你的档案系统地址:
```
{
"@class" : "org.apereo.cas.services.RegexRegisteredService",
"serviceId" : "^https://你的档案系统地址/.",
"name" : "企业档案管理系统",
"id" : 10000,
"evaluationOrder" : 100
}
```
注意:serviceId的正则需要完全匹配档案系统地址,比如档案地址是https://archive.xxx.com,正则就写^https://archive\.xxx\.com/.https://cas.你的企业域名.com:8443/cas/login,能打开登录页说明认证中心部署成功。分两种场景,对应不同类型的档案管理软件:
绝大多数商业档案软件已经内置CAS单点登录支持,直接按以下步骤配置:
https://cas.你的企业域名.com:8443/cashttps://你的档案系统地址/cas/callbackhttps://cas.你的企业域名.com:8443/cas/p3/serviceValidate
如果是自研项目,直接整合CAS客户端,步骤如下:
application.properties中添加以下完整配置,替换对应地址:
```
cas.enabled=true
cas.server-url-prefix=https://cas.你的企业域名.com:8443/cas
cas.server-login-url=${cas.server-url-prefix}/login
cas.client-host-url=https://你的档案系统地址
cas.validation-url=${cas.server-url-prefix}/p3/serviceValidate
```
@EnableCasClient,示例:
```
@SpringBootApplication
@EnableCasClient
public class ArchiveApplication {
public static void main(String[] args) {
SpringApplication.run(ArchiveApplication.class, args);
}
}
```
casadmin,密码cas123456,点击登录检查CAS服务配置文件中的serviceId正则是否正确,必须完整匹配档案系统的访问协议和域名,服务ID不能和其他已注册服务重复。
检查CAS认证中心和档案系统是否可以通过域名互相访问,禁止使用localhost做测试,必须用可解析域名,同时确保两端协议一致(同为HTTP或HTTPS)。
检查档案系统是否开启了session共享,核对CAS端serviceId配置,同时检查浏览器是否禁用了第三方Cookie,调整设置后即可解决。