2012-01-20 116 views
1

我有雙重身份驗證問題。我通過始終位於頂部的彈出窗口實現了身份驗證表單。但我有問題可能與應用,甚至在開始之前,使被Tomcat的認證請求攔截器:GWT/EXT + Spring Security應用程序中的雙重身份驗證

用戶名和密碼都被http://127.0.0.1:8888要求。 該網站說:「春季安全應用」

如果我禁用攔截器,我在日誌中看到,SecurityContextHolder中把用戶作爲匿名。

所以我的問題是: 我可以以某種方式禁用第一個Tomcat登錄屏幕?

我的春天,安全配置XML是:

<?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-3.0.xsd 
           http://www.springframework.org/schema/security 
           http://www.springframework.org/schema/security/spring-security-3.0.xsd"> 


<authentication-manager alias="authenticationManager"> 
    <authentication-provider ref="customAuthenticationProvider"/> 
</authentication-manager> 

<beans:bean id="customAuthenticationProvider" class="com.myCompany.model.security.CustomAuthenticationProvider" > 
    <beans:property name="databaseId" value="${configuration.databaseId}" /> 
    <beans:property name="applicationId" value="${configuration.applicationId}" /> 
</beans:bean> 

<http auto-config="true" > 
     <intercept-url pattern="/myApp/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/> 
     <intercept-url pattern="/MyApp.html*" access="IS_AUTHENTICATED_ANONYMOUSLY"/> 
     <intercept-url pattern="/gwt/**" access="ROLE_USER"/> 
     <intercept-url pattern="/**/*.html" access="ROLE_USER"/> 

     <intercept-url pattern="/css/**" filters="none"/> 
     <intercept-url pattern="/**" access="ROLE_USER" /> 

     <http-basic /> 
</http> 

<global-method-security secured-annotations="enabled" /> 

</beans:beans> 
+1

你的問題是,Spring Security基於重定向。我曾經試圖與它鬥爭,但它需要深入SS內部,所以我已經從這個想法中辭職了。在我看來,使用SS只是過濾頻道,在這種情況下,簡單的HttpFilter就足夠了。 –

+0

@lechlukasz:我不確定你期望我做什麼。你能寫一些詳細的解釋嗎? 我試圖除去所有攔截器,並只留下這一個: '<截距-URL模式= '/ **' 存取= 'ROLE_ANONYMOUS,ROLE_CHANGE_PASS,ROLE_VIEWER,​​ROLE_USER,ROLE_ADMIN'/>' 但SS對待用戶作爲匿名,即使在認證之後。 – Mario

回答

0

你的問題是不是太清楚。您提到了一個Tomcat登錄屏幕,我認爲它是您的Web應用程序的第一個屏幕,允許用戶登錄。

如果這是正確的,並且您的登錄頁面被命名,請說login.html,所要做的就是配置的攔截器允許匿名訪問這個頁面 -

<intercept-url pattern="/**/login.*" access="IS_AUTHENTICATED_ANONYMOUSLY"/> 
<intercept-url pattern="/gwt/**" access="ROLE_USER"/> 
<intercept-url pattern="/**/*.html" access="ROLE_USER"/> 

<intercept-url pattern="/css/**" filters="none"/> 
<intercept-url pattern="/**" access="ROLE_USER" /> 
1

如果我理解正確的方式你的問題,你有雙重認證例如一個問題a Tomcat身份驗證或Apache Basic身份驗證彈性身份驗證機制。

雖然最後一個項目我曾與一個Apache的基本認證安全機制有關的問題。在發佈之前,我有一項任務,通過簡單的Apache Basic Auth「保護」訪問該網站。通過在阿帕奇配置啓用此開始做同樣的:「Spring Security的應用程序」已經顯示出所有的時間

這個問題的解決方案是禁用自動配置

<security:http auto-config="false" ...> 
    ... 
</security:http> 
相關問題