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入门程序

  

 

posted @ 2019-02-26 11:52  林财钦  阅读(2407)  评论(0编辑  收藏  举报