Spring Security 4.0 CAS實現單點登入
JDK 8
Tomcat 7
SpringMVC-4.2.0.RELEASE
Spring Security 4.2.0.RELEASE
CAS-Client 3.3.3
CAS-Server 4.0.0
2、MAVEN的pom.xml
Java程式碼
- <!--Spring -->
- <dependency>
- <groupId>org.springframework</groupId>
-
<artifactId>spring-core</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>${spring.version}</version>
-
</dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
-
<groupId>org.springframework</groupId>
- <artifactId>spring-context-support</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aop</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-aspects</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-tx</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-orm</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-expression</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-instrument</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-instrument-tomcat</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-jdbc</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-web</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-webmvc-portlet</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-web</artifactId>
- <version>${spring.security.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-config</artifactId>
- <version>${spring.security.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework.security</groupId>
- <artifactId>spring-security-cas</artifactId>
- <version>${spring.security.version}</version>
- </dependency>
- <dependency>
- <groupId>org.jasig.cas.client</groupId>
- <artifactId>cas-client-core</artifactId>
- <version>3.3.3</version>
- <!-- 排除log4j包衝突 -->
- <exclusions>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>log4j-over-slf4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
影音先鋒電影http://www.iskdy.com/
3、配置CAS-Server
1)、下載CAS-Server的Zip包[http://developer.jasig.org/cas/]
解壓後將modules資料夾中的[cas-server-webapp-4.0.0.war]放到tomcat的webapps資料夾中、重新命名為cas.war。
啟動tomcat、解壓war包、瀏覽器中輸入[http://localhost:8080/cas/]
開啟CAS-Server的登入畫面、輸入預設使用者名稱/密碼:[casuser/Mellon]、提示[login success]即登入成功。
2)、修改CAS-Server配置檔案、支援資料庫登入校驗
開啟[../tomcat/webapps/cas/WEB-INF/deployerConfigContext.xml]檔案
完成的配置檔案
Java程式碼
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed to Jasig under one or more contributor license
- agreements. See the NOTICE file distributed with this work
- for additional information regarding copyright ownership.
- Jasig licenses this file to you under the Apache License,
- Version 2.0 (the "License"); you may not use this file
- except in compliance with the License. You may obtain a
- copy of the License at the following location:
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
- <!--
- | deployerConfigContext.xml centralizes into one file some of the declarative configuration that
- | all CAS deployers will need to modify.
- |
- | This file declares some of the Spring-managed JavaBeans that make up a CAS deployment.
- | The beans declared in this file are instantiated at context initialization time by the Spring
- | ContextLoaderListener declared in web.xml. It finds this file because this
- | file is among those declared in the context parameter "contextConfigLocation".
- |
- | By far the most common change you will need to make in this file is to change the last bean
- | declaration to replace the default authentication handler with
- | one implementing your approach for authenticating usernames and passwords.
- +-->
- <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"
- xmlns:c="http://www.springframework.org/schema/c"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:util="http://www.springframework.org/schema/util"
- xmlns:sec="http://www.springframework.org/schema/security"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
- http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
- http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
- <!--
- | The authentication manager defines security policy for authentication by specifying at a minimum
- | the authentication handlers that will be used to authenticate credential. While the AuthenticationManager
- | interface supports plugging in another implementation, the default PolicyBasedAuthenticationManager should
- | be sufficient in most cases.
- +-->
- <bean id="authenticationManager" class="org.jasig.cas.authentication.PolicyBasedAuthenticationManager">
- <constructor-arg>
- <map>
- <!--
- | IMPORTANT
- | Every handler requires a unique name.
- | If more than one instance of the same handler class is configured, you must explicitly
- | set its name to something other than its default name (typically the simple class name).
- -->
- <entry key-ref="proxyAuthenticationHandler" value-ref="proxyPrincipalResolver" />
- <!-- <entry key-ref="primaryAuthenticationHandler" value-ref="primaryPrincipalResolver" />-->
- <entry key-ref="dbAuthHandler" value-ref="primaryPrincipalResolver"/>
- </map>
- </constructor-arg>
- <!-- Uncomment the metadata populator to allow clearpass to capture and cache the password
- This switch effectively will turn on clearpass.
- <property name="authenticationMetaDataPopulators">
- <util:list>
- <bean class="org.jasig.cas.extension.clearpass.CacheCredentialsMetaDataPopulator"
- c:credentialCache-ref="encryptedMap" />
- </util:list>
- </property>
- -->
- <!--
- | Defines the security policy around authentication. Some alternative policies that ship with CAS:
- |
- | * NotPreventedAuthenticationPolicy - all credential must either pass or fail authentication
- | * AllAuthenticationPolicy - all presented credential must be authenticated successfully
- | * RequiredHandlerAuthenticationPolicy - specifies a handler that must authenticate its credential to pass
- -->
- <property name="authenticationPolicy">
- <bean class="org.jasig.cas.authentication.AnyAuthenticationPolicy" />
-
相關推薦
Spring Security 4.0 CAS實現單點登入
1、各framework版本資訊 JDK 8 Tomcat 7 SpringMVC-4.2.0.RELEASE Spring Security 4.2.0.RELEASE CAS-Client 3.3.3 CAS-Serv
Spring Security原始碼分析十二:Spring Security OAuth2基於JWT實現單點登入
單點登入(英語:Single sign-on,縮寫為 SSO),又譯為單一簽入,一種對於許多相互關連,但是又是各自獨立的軟體系統,提供訪問控制的屬性。當擁有這項屬性時,當用戶登入時,就可以獲取所有
spring security整合cas實現單點登入
spring security整合cas 0.配置本地ssl連線 操作記錄如下: =====================1.建立證書檔案thekeystore ,並匯出為thekeystore.crt cd C:\Users\23570\keystore C:\Users\23570\keystore&
CAS實現單點登入(SSO)
什麼是單點登入 單點登入(Single Sign On),簡稱為 SSO,是目前比較流行的企業業務整合的解決方案之一。SSO的定義是在多個應用系統中,使用者只需要登入一次就可以訪問所有相互信任的應用系統。 我們目前的系統存在諸多子系統,而這些子系統是分別部署在不
CAS實現單點登入SSO執行原理探究(終於明白了)
一、不落俗套的開始 1、背景介紹 單點登入:Single Sign On,簡稱SSO,SSO使得在多個應用系統中,使用者只需要登入一次就可以訪問所有相互信任的應用系統。 CAS框架:CAS(Central Authentication Service)是實現S
CAS實現單點登入(sso)搭建流程 伺服器端搭建
一、簡介 1、cas是有耶魯大學研發的單點登入伺服器 2、所用環境 · Linux系統 · To
cas實現單點登入-應用場景和完整配置
Cas 簡介 1、什麼是CAS CAS是一個單點登入(SSO)的框架。單點登入是目前比較流行的服務於企業業務整合的解決方案之一,SSO使得在多個應用系統中,使用者只需要登入一次就可以訪問所有相互信任的應用系統。 2、CAS的主要結構 CAS包括兩部分:
CAS 實現單點登入oos(2)
前面已經介紹了CAS伺服器的搭建,詳情見:搭建CAS單點登入伺服器。然而前面只是簡單地介紹了伺服器的搭建,其驗證方式是原始的配置檔案的方式,這顯然不能滿足日常的需求。下面介紹下通過mysql資料庫認證的方式。 一、CAS認證之mysql資料庫認證 1、在mysql中新建一個cas資料庫並建立us
Spring Session+Redis零侵入實現單點登入
Spring Session 實現單點登入 此種方式相對於上節所說使用原生(Jedis+Jackson+Cookie+Filter)的方式實現起來更加簡便,同時對業務程式碼的侵入性也十分之小,其原理與原生方式類似,並通過對HttpServletRequest和HttpSer
基於CAS實現單點登入(SSO):CAS+LDAP實現單點登入認證
[一]、概述 CAS是N個系統的中心認證入口,而貫穿多個系統的使用者資訊是共用的,應該被單獨維護,而這些資訊可能屬於不用的系統,不用的組織,不用的國家,從而形成了樹形結構,而使用關係型資料庫維護樹形結構資訊是它的弱點,這就是本文CAS和LDAP整合的初衷。 本來主要
Shiro & CAS 實現單點登入
概覽 單點登入主要用於多系統整合,即在多個系統中,使用者只需要到一箇中央伺服器登入一次即可訪問這些系統中的任何一個,無須多次登入。 部署伺服器 Tomcat預設沒有開啟HTTPS協議,所以這裡直接用了HTTP協議訪問。為了能使客戶端在HTTP協議下單點登入成
CAS實現單點登入的時序圖
CAS單點登入時序圖: PS:該圖為自己根據CAS驗證過程及真例項子總結出來的時序圖,其中步驟8和步驟9未證實,如果有不對的地方歡迎指正。 猜想: 一直用HttpWatch觀察後臺html請求狀態,所以步驟8和9只能看到一次從cas server的重定向,始終找不到步驟8
CAS實現單點登入(二):自定義的使用者驗證登入
上一篇演示單點登入服務端認證機制採用的是cas server預設的使用者名稱和密碼(admin/admin)。今天介紹正常專案中如何通過驗證DB中的使用者資料,來驗證使用者的密碼的合法性 自定義驗證登入有兩種方式: 採用cas-server預設的資料庫查詢
使用Spring Security OAuth2進行簡單的單點登入
1.概述 在本教程中,我們將討論如何使用Spring Security OAuth和Spring Boot實現SSO - 單點登入。 我們將使用三個單獨的應用程式: 授權伺服器 - 這是中央身份驗證機制 兩個客戶端應用程式:使用SSO的應用程式 非常簡單地說,當用戶試圖訪問客戶端應用程式中的安全頁面時,他
Spring Security基於Oauth2的SSO單點登入怎樣做?一個註解搞定
![mark](https://img2018.cnblogs.com/blog/1769816/202003/1769816-20200302103628233-400360122.png) ## 一、說明 單點登入顧名思義就是在多個應用系統中,只需要登入一次,就可以訪問其他相互信任的應用系統,免除多次登入
spring boot 1.5.4 整合shiro+cas,實現單點登入和許可權控制
1.安裝cas-server-3.5.2 官網:https://github.com/apereo/cas/releases/tag/v3.5.2 注意: 輸入 <tomcat_key> 的金鑰口令 (如果和金鑰庫口令相同, 按回車) ,這裡直接回車,也採用keystore密碼changei
spring boot中spring security實現單點登入,傳統模式(一)
單點登入是什麼? 一個系統中可能會引用別的很多系統。單點登入就是解決,一次登入,就可以訪問所有的系統。 每次瀏覽器向一個域名傳送http請求,會去查詢域名的cookie資訊拼接到http的header中傳送到伺服器。 cookie不能跨域。這個域是瀏覽器請求的域名,哪怕他們都是訪問一
cas+tomcat+shiro實現單點登入-4-Apache Shiro 整合Cas作為cas client端實現
目錄 4.Apache Shiro 整合Cas作為cas client端實現 Apache Shiro 整合Cas作為cas client端實現 第一步、新增maven依賴 <!-- shiro依賴包 -->
cas shiro spring實現單點登入
這裡貼出傳送門,來自幕課網大神。講了cas配置和cas的基本原理。 CAS deployerConfigContext.xml配置檔案 預設通過配置檔案管理授權登入賬戶 <bean id="primaryAuthentication
基於spring-security-oauth2實現單點登入(持續更新)
##基於spring-security-實現資料庫版## 文章程式碼地址:[連結描述][1]可以下載直接執行,基於springb