奇怪的一個,Spring Security Preauth「filters = none」not working
我使用siteminder彈簧安全,它工作正常。不過,我想要一個不受保護的url - 我們的loadBalancer在應用程序本身中需要一個「healthCheck」url。此網址未獲通過的SiteMinder截獲,但春天安全似乎在預認證適用於它無論如何..
如果我運行它在本地使用一個簡單的基於表單的安全配置以下工作(不包括過濾器):
在這種情況下,我可以瀏覽到localhost/myApp/resources/html/healthCheck.html而不觸及授權問題,但任何其他網址都會顯示登錄表單。迄今爲止所有看起來不錯!
但是當我部署到服務器我使用以下配置:
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/html/healthCheck.html" filters="none" />
<intercept-url pattern="/css/**" filters="none" />
<intercept-url pattern="/images/**" filters="none" />
<intercept-url pattern="/js/**" filters="none" />
<intercept-url pattern="/login" filters="none" />
<intercept-url pattern="/favicon.ico" filters="none" />
<intercept-url pattern="/*" access="hasAnyRole('ROLE_USER')" />
<custom-filter position="PRE_AUTH_FILTER" ref="siteminderFilter" />
</http>
當我瀏覽到:服務器/ MYAPP /資源/ HTML/healthCheck.html我得到以下錯誤:
java.lang.IllegalArgumentException: Cannot pass null or empty values to constructor
org.springframework.security.core.userdetails.User.<init>(User.java:94)
com.myApp.security.SecuritySBSUserDetailsService.loadUserByUsername(SecuritySBSUserDetailsService.java:119)
org.springframework.security.core.userdetails.UserDetailsByNameServiceWrapper.loadUserDetails(UserDetailsByNameServiceWrapper.java:53)
我認爲這是由UserDetailsService在沒有任何SM_USER的情況下實例化引起的。然而,過濾器=沒有適當的位置..並且在使用表單身份驗證時有效。任何想法可能會導致這種情況,或者更好 - 解決方法?
順便說一句,我的UserDetails服務配置如下:
<beans:bean id="siteminderFilter" class="org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter">
<beans:property name="principalRequestHeader" value="SM_USER" />
<beans:property name="exceptionIfHeaderMissing" value="false" />
<beans:property name="authenticationManager" ref="authenticationManager" />
</beans:bean>
即我已經設置exceptionIfHeaderMissing爲假,是否有幫助..
從您問題中的信息看來,您似乎正在使用不匹配的路徑。沒有證據表明有錯誤。很多人使用這種構造,所以也不太可能以前沒有發現過如此明顯的東西。 –