簡體   English   中英

Spring Security HTTPS攔截URL訪問

[英]Spring Security HTTPS intercept url access

我在弄清楚為什么每次在HTTPS中訪問我的網站時都沒有應用過濾器的問題,就像這樣: https://localhost:8443/initiator 因此,它無法正確重定向到未經身份驗證的用戶的登錄頁面。 如果我使用http://localhost:8080/initiator訪問它,則它應能正常工作。

我為我的Web應用程序使用了一個非常簡單的Spring安全配置。 如下所示,我希望每個鏈接都使用SSL。

<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.1.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-3.1.xsd">
  <http auto-config="false"  >
   <intercept-url pattern="/**" requires-channel="https"/>
   <intercept-url pattern="/initiator*" access="ROLE_USER" />
   <!-- Other configuration here like the logout, login, etc-->
  </http>
</beans>

我使用的是Spring Security版本3.1.3.RELEASE。 請注意,如果為http,則一切正常。 如果將其設置為https,它將不再起作用。

非常感謝你。

您是否嘗試過更改規則? 由於優先級高,我認為您去的時候第一條規則就是https://localhost:8443/initiator 我的意思是,以這種方式嘗試:

<intercept-url pattern="/initiator*" access="ROLE_USER" />
<intercept-url pattern="/**" requires-channel="https"/>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM