【发布时间】:2015-04-29 02:24:26
【问题描述】:
我们目前在运行 Grails 的 Tomcat 实例前使用 AWS ELB -> Apache。我们使用 Apache 将 http 请求重定向到 https 请求。这在我们的常规网站上对我们来说很好。尝试在 Chrome 上的 iframe 中嵌入我们的网站时出现问题。 Chrome 不喜欢 https 站点重定向到 http 页面(即使该页面随后重定向到 https)。发生这种情况的原因是,对于 Spring Security,它看起来像我们在 http 上,因为我们在负载均衡器后面。这是开发者工具中的网络乒乓球:
这是在 Chrome 上将同一页面放入 iframe 时的问题。
我们找到了许多解决方案,这些解决方案将允许 Spring Security Grails 插件将 http 请求重定向到特定 URL 模式的 https 请求。 Here 和 here 是其中的两个示例。我们已经通过让 Apache 拦截 http 请求并重定向到 https 解决了这个问题。
问题在于 Chrome 甚至不会在 iframe 中发出 http 请求。我们需要能够告诉 Spring Security,即使您收到的 saved request 使用的是 http,我们需要您在完成身份验证后将其更改为 https。
我们认为可能可行的一个解决方案是使用 contextRelative 而不是绝对 URL 更改为相对 URL,由于 ELB 代理,Spring Security 将其视为 http。这个post 似乎暗示相同,但解决方案也没有更改将 contextRelative 更改为“true”时生成的 URL。
我们如何告诉 Grails Spring Security 插件始终将 URL 格式化为相对或强制它们使用 https 方案,以便我们可以在 Chrome 中的 iframe 中运行应用程序?
【问题讨论】:
标签: grails iframe spring-security load-balancing http-redirect