【问题标题】:Spring 3 Security and Relative Redirect URLsSpring 3 安全和相对重定向 URL
【发布时间】:2011-05-31 15:34:57
【问题描述】:

我们在 Squid 代理后面有一个带有 Spring Security 的 Spring 3 应用程序。问题是 Spring 只知道内部 squid url,因此在 example.com/login 成功登录后,它不会重定向到 example.com/home,而是重定向到 internal.example.com

有谁知道如何处理这种情况?

我的配置:

<security:http use-expressions="true" auto-config="true">
    <security:intercept-url pattern="/" access="hasRole('ROLE_ANONYMOUS') or hasRole('ROLE_GENERAL_ADMINISTRATION')"/>
    <security:intercept-url pattern="/**" access="hasRole('ROLE_GENERAL_ADMINISTRATION')"/>
    <security:intercept-url pattern="/static/**" filters="none"/>
    <security:logout invalidate-session="true" logout-url="/logout" logout-success-url="/"/>
    <security:form-login login-page="/" default-target-url="/dashboard"/>
    <security:anonymous/>
</security:http>

编辑:

在我的情况下,管理员错误地设置了 mod_jk,因此 squid 和上述配置一切正常。

【问题讨论】:

  • 我在重定向方面也有同样的问题,不仅仅是安全问题......

标签: java spring spring-security squid


【解决方案1】:

我在 Apache HTTP 反向代理和一些愚蠢的应用程序后面有一个带有 Spring 安全性的 Web 应用程序,它的行为与您在上面描述的一样,我们的解决方案是使用 mod_rewrite 模块

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

无论如何,你所说的很奇怪,因为正确的 Spring 安全配置应该使用相对 url,并且在 url 中使用天气、内部或外部主机无关紧要。

如果你配置 URL

 <security:form-login login-page="//login.jsp" login-processing-url="/login" always-use-default-target="true"/>

在内部或外部 URL 中的行为方式应该相同,这听起来像是配置中的问题。

【讨论】:

  • 问题在于example.com 实际上是internal.example.com 的代理(鱿鱼)。 spring 应用部署到internal.example.com。这是它知道的唯一网址。但是用户应该/应该只看到example.com 而不是internal.example.com
  • 能否请您发布 Spring Security 配置?但它看起来确实像 Squid 配置问题。
  • 添加了我的配置。但是,管理员的 jkMount 设置不正确,这就是问题所在。你是对的,Spring Sec 正在处理所有事情。
  • @john 你能提供这些细节吗,因为我也遇到了这个问题
【解决方案2】:

我有一个类似的问题,在我的(当前是 PHP)应用程序前面有一个 nginx 反向代理,但其他人建议修复 URL 的工作在代理上完成,例如http://www.informit.com/articles/article.aspx?p=169534:

响应标头重新映射。响应标头可能包含 明确指向内容 Web 服务器的信息。一 例如,与重定向一起使用的“Location:”标头。这 反向代理服务器重新映射“位置:”字段,替换 引用具有自己地址的内容 Web 服务器。

还有一个相关问题的答案:"Redirect to https for few services using spring"

【讨论】:

    猜你喜欢
    • 2021-01-21
    • 1970-01-01
    • 2016-11-18
    • 2014-09-10
    • 2021-10-11
    • 1970-01-01
    • 1970-01-01
    • 2013-09-02
    • 1970-01-01
    相关资源
    最近更新 更多