CAS单点登录入门

Posted lcaiqin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CAS单点登录入门相关的知识,希望对你有一定的参考价值。

一、单点登录简介

  SOO是现在企业比较流行的业务整合解决方案之一,定义解决登录,可以应用在不同系统中,用户只需要登录一次,就可以访问所有相互信任的应用系统(模块开发、同家公司不同产品等等),例如百度,旗下的子系统。

架构图如下

技术图片

二、环境搭建(准备需要用的cas-server包并配置)

   1.从CAS官网下载:上cas的官网下载cas server 官网地址:https://github.com/Jasig/cas/releases

  2.准备一份新的tomcat

  3.解压出cas-server包在”cas-server-4.0.0modules下的”cas-server-webapp-4.0.0.war复制一份到新的tomcat中运行。

  技术图片

  tomcat启动,运行效果如下。

  技术图片

  浏览器浏览效果如下:默认的账号:casuser    密码:Mellon    此默认配置可以在“apache-tomcat-7.0.93webappscasWEB-INFdeployerConfigContext.xml” 中修改

  技术图片

    4.配置cas 去除Https认证

    1.在apache-tomcat-7.0.93webappscasWEB-INFdeployerConfigContext.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.93webappscasWEB-INFspring-configuration icketGrantingTicketCookieGenerator.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.93webappscasWEB-INFspring-configurationwarnCookieGenerator.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入门程序

  

 

以上是关于CAS单点登录入门的主要内容,如果未能解决你的问题,请参考以下文章

开源单点登录系统CAS入门

CAS单点登录入门

CAS单点登录系统入门--分布式登录验证

使用 CAS 在 Tomcat 中实现单点登录

SSO之CAS单点登录实例演示

SSO之CAS单点登录实例演示