84669 Lernen von Personen
152542 Lernen von Personen
20005 Lernen von Personen
5487 Lernen von Personen
7821 Lernen von Personen
359900 Lernen von Personen
3350 Lernen von Personen
180660 Lernen von Personen
48569 Lernen von Personen
18603 Lernen von Personen
40936 Lernen von Personen
1549 Lernen von Personen
1183 Lernen von Personen
32909 Lernen von Personen
光阴似箭催人老,日月如移越少年。
CAS 现在大多数SSO都是采用的CAS解决方案,楼主可以研究一下。
SSO 流程图SSO 是利用 cookie 来实现的。简单来说就是登录之后将认证信息存放在 cookie 中。当有app请求时可以先在自己的应用中校验是否登录。如果未登录将跳转至认证系统,此时认证系统检测cookie信息,如果有登录信息,跳回请求系统。
cookie
app
多谢 @kevinz 的指点,我现在采用这样的方式:
每个 APP 使用 Tomcat JDBCRealm 进行认证 (Authentication),但使用 Spring Security 进行授权。两者基于相同的用户信息数据库。
在 Tomcat 中打开 SSO -- 这个很重要,否则访问同一个域中其它 webapp 时,不会带上 Cookie,也就无法认证了
在每个 webapp 中,配置 Web.xml 使用 Tomcat 进行认证 -- 如果用 Spring 进行认证,则 Tomcat 的 SSO 不起作用
在每个 webapp 中,配置 spring,使用 J2eePreAuthenticatedProcessingFilter,进行权限控制 (Authorization)
spring.xml 中的配置
<bean id="encoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder"> <constructor-arg name="strength" value="11" /> </bean> <bean id="forbiddenEntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"/> <security:http auto-config="false" use-expressions="true" entry-point-ref="forbiddenEntryPoint"> <security:custom-filter position="PRE_AUTH_FILTER" ref="preAuthFilter"/> <security:intercept-url pattern="/index/**" access="hasAnyRole('ROLE_SUPER')" /> <security:session-management session-fixation-protection="none"/> <security:csrf disabled="true"/> </security:http> <bean id="preauthAuthProvider" class="org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationProvider"> <property name="throwExceptionWhenTokenRejected" value="true"/> <property name="preAuthenticatedUserDetailsService"> <bean id="userDetailsServiceWrapper" class="org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper"> <property name="userDetailsService" ref="nosUserDetailsService" /> </bean> </property> </bean> <bean id="preAuthenticatedProcessingFilterEntryPoint" class="org.springframework.security.web.authentication.Http403ForbiddenEntryPoint"/> <bean id="webXmlMappableAttributesRetriever" class="org.springframework.security.web.authentication.preauth.j2ee.WebXmlMappableAttributesRetriever"/> <bean id="simpleAttributes2GrantedAuthoritiesMapper" class="org.springframework.security.core.authority.mapping.SimpleAttributes2GrantedAuthoritiesMapper"> <property name="attributePrefix" value=""/> </bean> <bean id="j2eeBasedPreAuthenticatedWebAuthenticationDetailsSource" class="org.springframework.security.web.authentication.preauth.j2ee.J2eeBasedPreAuthenticatedWebAuthenticationDetailsSource"> <property name="mappableRolesRetriever" ref="webXmlMappableAttributesRetriever"/> <property name="userRoles2GrantedAuthoritiesMapper" ref="simpleAttributes2GrantedAuthoritiesMapper"/> </bean> <bean id="preAuthFilter" class="org.springframework.security.web.authentication.preauth.j2ee.J2eePreAuthenticatedProcessingFilter"> <property name="authenticationManager" ref="authenticationManager"/> <property name="authenticationDetailsSource" ref="j2eeBasedPreAuthenticatedWebAuthenticationDetailsSource"/> </bean> <security:authentication-manager alias="authenticationManager"> <security:authentication-provider ref="preauthAuthProvider"/> </security:authentication-manager>
CAS 现在大多数SSO都是采用的CAS解决方案,楼主可以研究一下。
SSO 流程图
SSO 是利用
cookie
来实现的。简单来说就是登录之后将认证信息存放在cookie
中。当有app
请求时可以先在自己的应用中校验是否登录。如果未登录将跳转至认证系统,此时认证系统检测cookie
信息,如果有登录信息,跳回请求系统。多谢 @kevinz 的指点,我现在采用这样的方式:
每个 APP 使用 Tomcat JDBCRealm 进行认证 (Authentication),但使用 Spring Security 进行授权。两者基于相同的用户信息数据库。
在 Tomcat 中打开 SSO -- 这个很重要,否则访问同一个域中其它 webapp 时,不会带上 Cookie,也就无法认证了
在每个 webapp 中,配置 Web.xml 使用 Tomcat 进行认证 -- 如果用 Spring 进行认证,则 Tomcat 的 SSO 不起作用
在每个 webapp 中,配置 spring,使用 J2eePreAuthenticatedProcessingFilter,进行权限控制 (Authorization)
spring.xml 中的配置