繁体   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