我的要求是提供:我可以在同一個彈簧安全配置中放置3種不同的身份驗證方案嗎?
- Userid基於密碼的驗證。
- 打開基於ID的認證
- 基於URL的認證(其定製SSO IMPL我們)
。
我試圖在Spring安全以插入到現有的項目作爲(剝離下來爲簡單起見代碼):
<?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">
<http auto-config="false">
<remember-me user-service-ref="rememberMeUserService" key="some custom key" /> <!-- TODO: Key made for testing reasons.... -->
<intercept-url pattern='/mainApplication/Main screen.html' access="ROLE_ADMIN"/>
<intercept-url pattern='/**' filters="none"/> <!-- Allow entry to login screen -->
<openid-login authentication-failure-url="/Login.html?error=true" default-target-url="/mainApplication/Main screen.html" user-service-ref="openIdUserService"/>
<form-login login-page="/Login.html" authentication-failure-url="/Login.html?error=true" always-use-default-target="true" default-target-url="/mainApplication/Main screen.html"/>
</http>
<beans:bean id="rememberMeUserService" class="mypackage.CustomUserService">
<beans:property name="usersService" ref="usersService"></beans:property>
</beans:bean>
<!-- Common login shared entry-point for both Form and OpenID based logins -->
<beans:bean id="entryPoint" class="org.springframework.security.ui.webapp.AuthenticationProcessingFilterEntryPoint">
<beans:property name="loginFormUrl" value="/Login.html" />
</beans:bean>
<authentication-manager alias="authenticationManager"/>
<beans:bean id="MyCustomAuthenticationProvider" class="mypackage.CustomAuthenticationProvider">
<custom-authentication-provider />
<beans:property name="usersService" ref="usersService"></beans:property>
</beans:bean>
<beans:bean id="openIdAuthenticationProvider" class="org.springframework.security.providers.openid.OpenIDAuthenticationProvider">
<custom-authentication-provider />
<beans:property name="userDetailsService" ref="openIdUserService"/>
</beans:bean>
<beans:bean id="openIdUserService" class="mypackage.OpenIDUserDetailsService">
<beans:property name="usersService" ref="usersService"/>
</beans:bean>
<!-- Great, now i want to include SSO based sign on -->
<!-- need to intercept a url of the form : /myApp/customLogin/<key> where <key> is my token key -->
</beans:beans>
如上面提到的,我需要跟蹤的形式的URL:/對myApp/customLogin/12345,其中1235是令牌密鑰,我們最初使用(剝離下來的簡單代碼)
<servlet-mapping>
<servlet-name>mySSOCapture</servlet-name>
<url-pattern>/myApp/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>/MyServlet</url-pattern>
</servlet-mapping>
我應該怎麼辦這裏讓Spring Security可以幫助我管理這個第三認證方案?
一個推論的問題是: 我可以在同一個項目中多項認證供應商? 如果是的話,他們怎麼能匹配到不同的功能(例如,一個提供基於URL的認證,一個提供anonomous身份驗證等)?
SSO:對單點登錄(用戶僅通過具有令牌身份驗證)。上面寫的servlet映射在我的web.xml中。公開識別認證和用戶名密碼驗證正在fine.My登錄頁面包含兩種形式之一正常登錄和其他開放ID登錄基礎。 – 2009-11-05 05:36:18