【问题标题】:Spring Security HTTPS intercept url accessSpring Security HTTPS 拦截 url 访问
【发布时间】:2013-06-19 09:16:04
【问题描述】:

我无法弄清楚为什么每当我以 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,它将不再有效。

非常感谢。

【问题讨论】:

    标签: spring ssl https spring-security tomcat7


    【解决方案1】:

    您是否尝试过交换规则?由于优先级,我认为当你去https://localhost:8443/initiator 时,会被第一条规则所采用。我的意思是,尝试这种方式:

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

    【讨论】:

      猜你喜欢
      • 2013-06-04
      • 1970-01-01
      • 2012-08-15
      • 1970-01-01
      • 2012-07-20
      • 2013-10-27
      • 1970-01-01
      • 2017-06-15
      • 1970-01-01
      相关资源
      最近更新 更多