【问题标题】:Grails - SSL and Spring security coreGrails - SSL 和 Spring 安全核心
【发布时间】:2012-06-01 13:03:55
【问题描述】:

我想让我的应用程序在启用 SSL 的情况下专门运行。 我正在使用 Spring Security 核心插件。

这就是我在Config.groovy 中尝试这样做的方式:

grails.plugins.springsecurity.portMapper.httpPort = 8080
grails.plugins.springsecurity.portMapper.httpsPort = 8443
grails.plugins.springsecurity.secureChannel.definition = [ '/**' : 'REQUIRES_SECURE_CHANNEL']

每次我尝试使用 HTTP 访问 URL 时,我都希望这会导致重定向。 但是,我永远不会被重定向,并且可以通过 HTTP 和 HTTPS 导航。我可以添加我正在使用grails run-app -https启动我的应用程序

我错了吗?

欢迎提出任何建议。

【问题讨论】:

    标签: http grails ssl https spring-security


    【解决方案1】:

    您的配置中是否声明了自定义过滤器链?

    在这种情况下,您可能需要将“channelProcessingFilter”添加到您的链中

    http://static.springsource.org/spring-security/site/docs/3.0.x/reference/security-filter-chain.html

    【讨论】:

      【解决方案2】:

      您也可以尝试使用 forceHttps 选项

      grails.plugins.springsecurity.auth.forceHttps = true
      

      【讨论】:

        【解决方案3】:

        您没有任何通配符,因此该定义实际上与根 URL (/) 匹配,但其下方没有任何内容 (/foo)。你想要的是:

        grails.plugins.springsecurity.secureChannel.definition = [ '/**' : 'REQUIRES_SECURE_CHANNEL']
                                                                     ^^
        

        (您可以清楚地看到the documentation 中的通配符:-)

        最后,如果您的服务器位于负载平衡器或其他隐藏协议的防火墙后面,请查看同一页面以获取有关检查标头的说明。

        【讨论】:

        • 真的很抱歉,我编辑了我的问题,但我的代码中已经有了通配符。如果这很重要,我会在 Fedora 系统上的 localhost 上尝试这个。
        猜你喜欢
        • 2011-10-19
        • 1970-01-01
        • 2016-04-16
        • 2012-08-17
        • 2016-06-12
        • 2015-12-09
        • 2018-11-02
        • 2014-09-17
        • 2015-04-09
        相关资源
        最近更新 更多