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

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM