如何获得 HTTP 100 继续在嵌入式 Grizzly 上使用 WebDAV?

发布于 2024-12-19 10:00:05 字数 1005 浏览 2 评论 0原文

我使用带有嵌入式 Grizzly servlet 容器 (2.1.7) 的 Milton WebDAV 服务器 (1.6.8),在其默认配置中,PUT 请求(至少由 Cyber​​duck 发出)不起作用。我已将问题追溯到如何处理 HTTP 100 Continue 的问题(它显然也影响 Jetty),这是 米尔顿邮件列表bug tracker 说这是 servlet 容器的错误,它试图巧妙地处理“透明的期望/继续处理”。

是的,透明处理期望的容器继续有效地破坏了 Webdav 的 HTTP 安全性。 HTTP 使用质询/响应安全模型,许多客户端都依赖于此。即,如果执行 PUT,他们将简单地执行未经身份验证的 PUT,并依靠 ExpectContinue 来确保在上传文件之前发出质询。

但是,通过对 ExpectContinue 进行透明处理,整个文件会在 milton API 能够检查当前用户是否经过身份验证并有权执行该操作之前上传。

根据您支持的客户和您的使用案例,这可能是完全不可接受的、令人讨厌的,也可能根本不是问题。

但是,一般来说,我认为您应该尝试找出是否可以禁用 Grizzly 的透明处理,然后重新启用 milton 中的支持。

我可以做什么来禁用 Grizzly 的透明期望/继续处理,这真的是正确的方法吗?另一种方法是关闭 Milton 中的期望/继续处理,但这似乎会破坏 WebDAV 身份验证。

更新:我现在也尝试了 Jetty (8.1.0.RC1),它表现出与 Grizzly 相同的行为:只有在关闭期望/继续处理的情况下,我才能使用默认设置来 PUT 文件不工作。

I am using the Milton WebDAV server (1.6.8) with an embedded Grizzly servlet container (2.1.7), and in their default configuration, PUT requests (at least as issued by Cyberduck) do not work. I have tracked the issue down to a problem with how HTTP 100 Continue is handled (it apparently also affects Jetty), a message on the Milton mailing list and bug tracker says it is the fault of the servlet container, which tries to be clever with "transparent expect/continue handling".

Yes, containers which transparently handle expect continue effectively break HTTP security for Webdav. HTTP uses a challenge/response security model and many clients rely on that. Ie if doing a PUT they will simply do an un-authenticated PUT and rely on ExpectContinue to ensure that the challenge is issued before the file is uploaded.

But with transparent handling of ExpectContinue the entire file gets uploaded before the milton API is able to check if the current user is authenticated and authorised to perform the action.

Depending on your supported clients and you use cases this can either be wholely unacceptable, a nuisance or not an issue at all.

But, generally, I think you should try to find out if Grizzly's transparent handling can be disabled, and then re-enable support in milton.

What can I do to disable Grizzly's transparent expect/continue handling, and is this really correct approach? The alternative would be to turn off expect/continue handling in Milton, but that seems to break WebDAV authentication.

Update: I also tried Jetty now (8.1.0.RC1), and it exhibits the same behaviour as Grizzly: only with expect/continue handling turned off can I PUT files, with the default settings it does not work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只是我以为 2024-12-26 10:00:05

关于 Grizly 2.x,您需要重写 ServletHandler 中的 sendAcknowledgment 方法,如下所示:

class MyServletHandler extends ServletHandler
{
    protected boolean sendAcknowledgment(final Request request,
        final Response response)
        throws IOException
    {
        if (authClient(request, response)
        {
            return super.sendAcknowledgment(request, response);
        }
        else
        {
            response.setStatus(HttpStatus.EXPECTATION_FAILED_417);
            return false;
        }
    }
}

希望它会有所帮助。

Regarding Grizly 2.x, you need to override sendAcknowledgment method in your ServletHandler like the following:

class MyServletHandler extends ServletHandler
{
    protected boolean sendAcknowledgment(final Request request,
        final Response response)
        throws IOException
    {
        if (authClient(request, response)
        {
            return super.sendAcknowledgment(request, response);
        }
        else
        {
            response.setStatus(HttpStatus.EXPECTATION_FAILED_417);
            return false;
        }
    }
}

Hope it will help.

攒一口袋星星 2024-12-26 10:00:05

请注意,透明的期望继续处理是否是一个问题取决于您的目标客户端应用程序是否使用期望继续身份验证。

我还没有对此进行过详细研究,因此我无法确定哪些容器进行透明处理,是否可以禁用它,或者哪些客户端应用程序需要它。

如果来自 Grizzly 或 Tomcat 的人可以对禁用容器处理的选项发表评论,那可能会很好。

Note that whether or not the transparent expect-continue handling is a problem depends on whether your targeted client applications uses expect-continue authentication or not.

I haven't researched this in too much detail yet, so I can't say with certainty which containers do transparent handling and whether or not it can be disabled, or what client applications require it.

Might be good if someone from Grizzly or Tomcat could comment on options for disabling the container handling.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文