【问题标题】:Jetty 9 removes URI FragmentsJetty 9 移除 URI 片段
【发布时间】:2014-10-01 12:23:24
【问题描述】:

我有一个 Web 应用程序,我想使用 web.xml 中的安全约束来保护它。

这里是来自web.xml的loginConfig

<login-config>
    <auth-method>FORM</auth-method>
    <realm-name>MyUserRealm</realm-name>
    <form-login-config>
        <form-login-page>/login/login.html</form-login-page>
        <form-error-page>/login/login-error.html</form-error-page>
    </form-login-config>
</login-config>

这里是安全限制:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Public</web-resource-name>
        <url-pattern>/login/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>
<security-constraint>
    <web-resource-collection>
        <web-resource-name>Private</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>**</role-name>
    </auth-constraint>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>

这很好,我被重定向到所需的login.html 站点,我可以在该站点正确地验证自己。 login.html 看起来像这样:

<form method="post" action="/j_security_check" id="loginform">
    <input class="login" value="" name="j_username" maxlength="25" type="text" placeholder="Username" required/>
    <input class="login" value="" name="j_password" maxlength="25" type="password" placeholder="Password" required/>
    <input name="submit" type="submit" value="Login" />
</form>

我现在的问题是,我用于原始 URL 的 URI 片段被转发到登录站点,但在身份验证后未包含回原始站点。因此,我丢失了我想在 WebApp 中检查的所有片段和参数。

有人知道为什么要删除 URI 片段吗?

【问题讨论】:

    标签: jetty web.xml form-authentication uri-fragment


    【解决方案1】:

    浏览器不会将 URI 片段发送到服务器。

    查看该主题的过去答案:https://stackoverflow.com/a/13503246/775715

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-06
      • 2014-05-28
      • 2016-10-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多