CAS单点登录入门
一、单点登录简介
SOO是现在企业比较流行的业务整合解决方案之一,定义解决登录,可以应用在不同系统中,用户只需要登录一次,就可以访问所有相互信任的应用系统(模块开发、同家公司不同产品等等),例如百度,旗下的子系统。
架构图如下
二、环境搭建(准备需要用的cas-server包并配置)
1.从CAS官网下载:上cas的官网下载cas server 官网地址:https://github.com/Jasig/cas/releases
2.准备一份新的tomcat
3.解压出cas-server包在”cas-server-4.0.0\modules下的”cas-server-webapp-4.0.0.war复制一份到新的tomcat中运行。
tomcat启动,运行效果如下。
浏览器浏览效果如下:默认的账号:casuser 密码:Mellon 此默认配置可以在“apache-tomcat-7.0.93\webapps\cas\WEB-INF\deployerConfigContext.xml” 中修改
4.配置cas 去除Https认证
1.在apache-tomcat-7.0.93\webapps\cas\WEB-INF\deployerConfigContext.xml p:requireSecure="false"配置这个属性
<!-- Required for proxy ticket mechanism. -->
<bean id="proxyAuthenticationHandler"
class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
p:httpClient-ref="httpClient" p:requireSecure="false" />
2.在apache-tomcat-7.0.93\webapps\cas\WEB-INF\spring-configuration\ticketGrantingTicketCookieGenerator.xml中配置如下属性
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<description>
Defines the cookie that stores the TicketGrantingTicket. You most likely should never modify these (especially the "secure" property).
You can change the name if you want to make it harder for people to guess.
</description>
<bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure="false" ---->改成false
p:cookieMaxAge="3600" ---->设置ticket的cookie,以秒为单位
p:cookieName="CASTGC"
p:cookiePath="/cas" />
</beans>
3.apache-tomcat-7.0.93\webapps\cas\WEB-INF\spring-configuration\warnCookieGenerator.xml 配置如下属性
<bean id="warnCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure="false" --->改成false
p:cookieMaxAge="3600" --->设置ticket的cookie,以秒为单位
p:cookieName="CASPRIVACY" p:cookiePath="/cas" />
4.重启tomcat即可。
三、Cas demo入门程序
本文作者:独而不孤
本文链接:https://www.cnblogs.com/lcaiqin/p/10436339.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步