【问题标题】:Spring Security 3.1 and Unsecured HTTP ChannelSpring Security 3.1 和不安全的 HTTP 通道
【发布时间】:2012-02-17 22:34:39
【问题描述】:

我们最近刚刚从 Spring Security 3.0 版升级到 3.1 版。我们的旧配置文件显然使用了一个已弃用的功能,您可以使用 'filter="none"' 选项禁用 块中的 块的安全性。这是我们旧的 applicationContext-security.xml 文件中的一个 sn-p:

<http ...>
    <intercept-url pattern="/resetPassword" filter="none" requires-channel="https" />
</http>

Spring Security 3.1 强制你定义额外的 块来关闭某些 URL 模式的安全性:

<http security="none" pattern="/resetPassword" />

问题:如何为这个新的 块强制使用 HTTPS 通道?

【问题讨论】:

    标签: java spring spring-security


    【解决方案1】:

    您使用的配置实际上并不需要 https,因为 filters="none" 意味着 Spring Security 不应该关注该请求。而对于 Spring Security 3 和 3.1,你应该使用类似的东西:

      <http use-expressions="true" ...>
        <intercept-url pattern="/resetPassword" access="permitAll" requires-channel="https" />
      </http>
    

    【讨论】:

    • 谢谢!通过其他一些小调整——即使用 hasAnyAuthority(...Roles...) 而不是直接命名角色——效果很好。
    猜你喜欢
    • 1970-01-01
    • 2016-12-27
    • 2013-09-21
    • 1970-01-01
    • 2013-07-17
    • 1970-01-01
    • 2016-05-06
    • 1970-01-01
    • 2019-06-25
    相关资源
    最近更新 更多