authentication - Safari , jetty : Websockets not working as authentication header is not sent

标签 authentication websocket safari jetty

我们有一个 Spring-MVC 应用程序,其 Websockets 部署在 Jetty 服务器上。我们还为 jetty 配置了如下所示的 HashLoginService。当应用程序启动时,我们可以在 FF、Chrome、Opera、IE 上使用完整的 websockets 功能访问它,但在 Safari 上则不行。我们唯一返回的是 401。禁用 HashLoginService 后,websockets 工作正常。 Jetty 或其他地方是否需要进行一些配置,以便 websocket 在 Safari 中通过身份验证工作。谢谢。

Safari version : 11.0.3(desktop version)
Jetty - 9.4 

jetty.xml:

  <Arg>
            <New class="org.eclipse.jetty.security.HashLoginService">
               <Set name="name">Default Realm</Set>
               <Set name="config"><SystemProperty name="jetty.home" default="."/>/etc/realm.properties</Set>
            </New>
         </Arg>
      </Call>

项目中的 web.xml:

<security-constraint>
            <web-resource-collection>
                <web-resource-name>username</web-resource-name>
                <url-pattern>/*</url-pattern>
            </web-resource-collection>
            <auth-constraint>
                <role-name>user-role</role-name>
            </auth-constraint>
        </security-constraint>

            <security-constraint>
                <web-resource-collection>
                    <web-resource-name>username</web-resource-name>
                    <url-pattern>/*</url-pattern>
                </web-resource-collection>
                <auth-constraint>
                    <role-name>user-role</role-name>
                </auth-constraint>
            </security-constraint>

        <security-role>
            <role-name>user-role</role-name>
        </security-role>

知道我们能做什么吗?谢谢。

最佳答案

Safari 和 WebSocket 显然不支持标准 HTTP 身份验证。

参见:https://bugs.webkit.org/show_bug.cgi?id=80362

您可以在不同的 stackoverflow 答案中找到一些解决方法。

HTTP headers in Websockets client API

关于authentication - Safari , jetty : Websockets not working as authentication header is not sent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49321148/

相关文章:

go - 如何使用 Gorilla 指定 WS ping 的频率

jboss - 瓦丁推送 : disable WebSocket and force Vaadin to use streaming

javascript - Chrome 和 Safari 中 Javascript 的奇怪行为

jquery - 在不刷新屏幕的情况下,使用 jQuery 更改不透明度在 Chrome 或 Safari 中不起作用

javascript - 在线多人游戏中常见 "tick"怎么办?

html - <td> 高度甚至不在 safari 中的 rowspan 旁边

asp.net - 将 SSRS 与 ASP.Net ReportViewer 一起使用

python - 我如何让这个 python 登录/注册程序工作? (我是Python新手)

objective-c - 如何使用 BetterAuthorizationSample? - cocoa

c# - 对 Flickr API 的签名请求签名无效(在控制台中模拟)