`
ginge
  • 浏览: 208629 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

单点登录(Single Sign On)设计实践

阅读更多

     转到Architecture Team后接手了公司的Framework, 单点登录也就落到我头上了.

 

     公司最开始使用的策略是基于Tomcat 的Realm SSO, 这种策略的缺点是所有应用都必须放在同一个Tomcat下面, 放到不同Tomcat下都必须再做一次登录.

     非常不利于HA.

 

 

     (一)转到Architecture Team后我就向SDC的头提议了CAS的SSO策略.

 

 

 

 

 

 

 

1)      The user choose to visit AMS

2)      When the user arrived, AMS will first check to see if the user is authenticated by trying to locate a service ticket. if not, the framework on which the AMS built will redirect the user to the login page

3)      Then Framework will ask the user to enter username and password which can identify herself/himself

4)      If authentication passed, the user will be redirected back to AMS

5)      The user is granted to visit AMS

6)      If at some time during the same session the user serfs the BMS’ page with a ticket

7)      BMS will first check to see if the user is authenticated by trying to locate a service ticket. And it found one, but it doesn’t know whether it’s valid, so it ask CAS to check it out

8)      Validation pass

9)      BMS is granted to visit.

 

 

    检验一种方法的好坏是看它是否满足实际需要, 这种策略扩展性很好, 但是却需要独立部署一个中央认证系统. 公司非常不希望增加一个潜在的单点故障. 所以这个策略没被采纳.

 

 

   (二) 不知什么原因, 后来SSO被外包公司负责. 他们提供了另外一种方案, 还是基于Tomcat, 利用Domain Cookie, 修改自己的Realm Authenticator, 可以提供真正的SSO体验. 最大的缺点是不同的Web Container要实现一整套不同的实现.

 

 

   (三) 我自然对方案(二)很不满意. 吸取(二)的优点, 提出了以下方案. 基于Spring Security 2.0, 提供自己的SSOTicketFilter和SSOAuthenticationFilter. SSOAuthenticationFilter负责本地用户认证, SSOTicketFilter负责跨系统用户认证. SSOAuthenticationFilter在用户通过验证后保存Ticket. 跨系统时另一个系统由于也是采用Framework, 它也就会用同样的SSOTicketFilter实现来检验用户提供的Ticket. 经过验证, 方案(三)能够提供真正的SSO体验, 公司最终采取了这个方案.

 

 

  以下样例配置:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
	xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.1.xsd">
                        
                        
	<beans:bean id="springSecurityFilterChain"
		class="org.springframework.security.util.FilterChainProxy">
		<beans:property name="filterChainMap">
			<beans:map>
				<beans:entry key="/**">
					<beans:list>
						<beans:ref local="httpSessionContextIntegrationFilter" />
						<beans:ref local="logoutFilter" />
						<beans:ref local="ssoTicketProcessingFilter" />
						<beans:ref local="ssoAuthenticationProcessingFilter" />
						<beans:ref local="exceptionTranslationFilter" />
						<beans:ref local="filterSecurityInterceptor" />
					</beans:list>
				</beans:entry>
			</beans:map>
		</beans:property>
	</beans:bean>
	<beans:bean id="httpSessionContextIntegrationFilter"
		class="org.springframework.security.context.HttpSessionContextIntegrationFilter">
	</beans:bean>
	<beans:bean id="exceptionTranslationFilter"
		class="org.springframework.security.ui.ExceptionTranslationFilter">
		<beans:property name="authenticationEntryPoint"
			ref="authenticationProcessingFilterEntryPoint">
		</beans:property>
	</beans:bean>
	<beans:bean id="ssoAuthenticationProcessingFilter"
		class="sso.SsoAuthenticationProcessingFilter">
		<beans:property name="authenticationManager" ref="authenticationManager"></beans:property>
		<beans:property name="defaultTargetUrl" value="/index.jsp"></beans:property>
		<beans:property name="authenticationFailureUrl" value="/login.jsp"></beans:property>
		<beans:property name="invalidateSessionOnSuccessfulAuthentication">
			<beans:value>true</beans:value>
		</beans:property>
	</beans:bean>
	<beans:bean id="authenticationProcessingFilterEntryPoint"
		class="org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint">
		<beans:property name="loginFormUrl" value="/login.jsp"></beans:property>
	</beans:bean>
	<beans:bean id="filterSecurityInterceptor"
		class="org.springframework.security.intercept.web.FilterSecurityInterceptor">
		<beans:property name="authenticationManager" ref="authenticationManager" />
		<beans:property name="accessDecisionManager" ref="accessDecisionManager"></beans:property>
		<beans:property name="objectDefinitionSource">
			<!-- <filter-invocation-definition-source>
				<intercept-url pattern="/secure/super/**" access="ROLE_WE_DONT_HAVE" />
				<intercept-url pattern="/secure/**"
					access="ROLE_SUPERVISOR,ROLE_TELLER" />
			</filter-invocation-definition-source>
			 -->
			<beans:value>
		        CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
                PATTERN_TYPE_APACHE_ANT
                /auth/login.action=ROLE_ANONYMOUS,ROLE_SUPERVISOR,ROLE_TELLER
                /**/*.action=ROLE_SUPERVISOR,ROLE_TELLER
                /**=ROLE_ANONYMOUS,ROLE_SUPERVISOR,ROLE_TELLER
		    </beans:value>
		</beans:property>
	</beans:bean>
	<beans:bean id="accessDecisionManager"
		class="org.springframework.security.vote.AffirmativeBased">
		<beans:property name="decisionVoters">
			<beans:list>
				<beans:ref local="voter"></beans:ref>
				<beans:bean class="org.springframework.security.vote.AuthenticatedVoter" />
			</beans:list>
		</beans:property>
	</beans:bean>
	<beans:bean id="voter" class="org.springframework.security.vote.RoleVoter">
	</beans:bean>
	<beans:bean id="ssoTicketProcessingFilter" class="sso.SsoTicketProcessingFilter">
		<custom-filter after="CAS_PROCESSING_FILTER" />
		<beans:property name="authenticationManager" ref="authenticationManager" />
		<beans:property name="defaultTargetUrl" value="/index.jsp"></beans:property>
		<beans:property name="authenticationFailureUrl" value="/j_spring_security_check"></beans:property>
		<beans:property name="invalidateSessionOnSuccessfulAuthentication">
			<beans:value>true</beans:value>
		</beans:property>
	</beans:bean>
	<beans:bean id="logoutFilter"
		class="org.springframework.security.ui.logout.LogoutFilter">
		<beans:constructor-arg>
			<beans:value>/login.jsp</beans:value>
		</beans:constructor-arg>
		<beans:constructor-arg>
			<beans:list>
				<beans:bean
					class="org.springframework.security.ui.logout.SecurityContextLogoutHandler"></beans:bean>
				<beans:bean class="sso.CleanTicketLogoutHandler"></beans:bean>
			</beans:list>
		</beans:constructor-arg>
	</beans:bean>
	<authentication-manager alias="authenticationManager" />
	<beans:bean id="casAuthenticationProvider" class="sso.SsoAuthenticationProvider">
		<custom-authentication-provider />
		<beans:property name="userDetailsService" ref="userDetailsService" />
	</beans:bean>
	<user-service id="userDetailsService">
		<user name="rod" password="rod"
			authorities="ROLE_SUPERVISOR, ROLE_USER, ROLE_TELLER" />
		<user name="dianne" password="dianne" authorities="ROLE_USER,ROLE_TELLER" />
		<user name="scott" password="scott" authorities="ROLE_USER" />
		<user name="peter" password="peter" authorities="ROLE_USER" />
	</user-service>
</beans:beans>

 

 

 

 

2
1
分享到:
评论
4 楼 alloyer 2009-04-12  
good artical
3 楼 yangbeisi 2008-12-30  
你好,现在在做这个,相关代码可以共享下吗,谢谢!邮箱是ybs261182@126.com
2 楼 sillycat 2008-12-01  
hi,你好。能有相关的代码吗?我的邮箱是magic_dreamer@126.com
1 楼 ginge 2008-08-12  
这两天想到,为何不模仿CAS, 将Service和Ticket放到url中呢? 这样就摆脱了Cookie Domain的限制了.

另外, 应用一次性的Ticket策略提高系统的安全性. 以下是正式描述:

1) Adopted one-time ticket authentication strategy instead of cookie strategy
and get rid of cookie domain constraints.

It uses one-time ticket to strengthen the security of the authentication. The unique ticket will be renewed after the operator

passes the authentication, including normal login authentication and SSO login authentication. The unique ticket will be

invalidated after the operator logs out

相关推荐

    单点登录Single Sign On

    单点登录是目前比较流行的企业业务整合的解决方案用户只需要登录一次就可以访问所有相互信任的应用系统。

    单点登陆(Single Sign On) 简称为 SSO

    单点登录(Single Sign On),简称为 SSO,是目前比较流行的企业业务整合的解决方案之一。SSO的定义是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统

    CAS单点登录SSO( Single Sign-On)

    NULL 博文链接:https://572327713.iteye.com/blog/2356519

    单点登录(Single Sign On)的介绍

    单点登录(Single Sign On),简称为 SSO,是目前比较流行的企业业务整合的解决方 案之一

    CAS 单点登录(Single Sign On)

    NULL 博文链接:https://zgq456.iteye.com/blog/2192979

    rubycas-server, 为web应用提供 单点登录(Single Sign-On) 认证,实现Jasig协议的服务器端.zip

    rubycas-server, 为web应用提供 单点登录(Single Sign-On) 认证,实现Jasig协议的服务器端 rubycas服务器版权Matt Zukowski贡献的部分是版权所有( c ) 2011 Urbacon有限公司。 其他部分是他们各自作者的版权。作者请...

    单点登录(Single Sign On)

    单点登录(SSO)的技术被越来越广泛地运用到各个领域的软件系统当中

    SSO(SingleSign-On)基于YMP框架实现的单点登录服务模块

    SSO (Single Sign-On) 基于YMP框架实现的单点登录服务模块

    eSSO Single Sign On

    LDAP eSSO Single Sign On

    single-sign-on-v2

    自定义的单点登录系统,可返回各个子系统的登录页及支持CAS Server集群。(https://github.com/liyingqiao121727/single-sign-on-v2)

    WebSphere环境下的SSO(Single sign-on:单点登录、全网漫游)实现之: -- SSO(Single Sign-On)实现步骤

    本文中作者给大家详细的演示了如何实现WebSphere服务器和webpshere服务器之间的SSO(“单点登录、全网漫游”),并且给大家详细地解释了实现过程中的关键点和相关选项的含义,并且给出了开发带有安全性能要求的web...

    django-mama-cas, Django 中央身份验证服务( CAS ) 单点登录(Single Sign-On) 服务器.zip

    django-mama-cas, Django 中央身份验证服务( CAS ) 单点登录(Single Sign-On) 服务器 MamaCAS MamaCAS是 Django 中央认证服务( CAS ) 单一登录和单一注销服务器。 它实现了 CAS 1.0.2.0和 3.0协议,包括一些可选的...

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

    单点登录(Single Sign On , 简称 SSO )是目前比较流行的服务于企业业务整合的解决方案之一, SSO 使得在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统。CAS(Central Authentication ...

    CAS单点登录(SSO)教程

    单点登录(Single Sign On , 简称 SSO )是目前比较流行的服务于企业业务整合的解决方案之一, SSO 使得在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统。CAS(Central Authentication ...

    SpringBoot整合SSO(single sign on)单点登录

    主要介绍了SpringBoot整合SSO(single sign on)单点登录,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

    Single Sign On 分析报告

    SSO 也称为单点登录,就是就是通过用户的一次性鉴别登录,即可获得需访问系统和应用软件的授权,在此条件下,管理员无需修改或干涉用户登录就能方便的实施希望得到的安全控制。 随着信息技术和网络技术的发展,各种...

    single sign on 分析报告

    SSO 也称为单点登录,就是就是通过用户的一次性鉴别登录,即可获得需访问系统和应用软件的授权,在此条件下,管理员无需修改或干涉用户登录就能方便的实施希望得到的安全控制。 随着信息技术和网络技术的发展,各种...

    单点登录个人总结

    单点登录,Single Sign On,也就是我们平时所说的SSO。一般大型的系统平台,都会用到这个东西。它解决了频繁登录、验证的过程,也就是用户的一次登录得到其他系统的信任。可以说:一次登录,全站漫游。实现单点登录...

    C# 单点登录

    单点登录(Single Sign On),简称为 SSO。SSO的定义是在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统。 在Microsoft Office SharePoint Server 2007中提供了实现单点登录的功能。

Global site tag (gtag.js) - Google Analytics