EventSource和基本的HTTP身份验证 [英] EventSource and basic http authentication

查看:189
本文介绍了EventSource和基本的HTTP身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道是否可以通过EventSource发送基本的HTTP身份验证凭据吗?

Does anyone know if it is possible to send basic http authentication credentials with EventSource?

推荐答案

EventSource与服务器将事件发送到客户端有关.我认为您需要双向通信进行身份验证.否则,您将如何发送实际凭据?

EventSource is about the server sending events to the client. I think you need bidirectional communication for authentication. How would you otherwise send the actual credentials?

WebSockets可以实现这一点.那是您要找的东西吗?

WebSockets, however, can achieve that. Is that what you are looking for?

更新:

4esn0k 所指出的,您可以利用cookie来实现所需的功能. Cookies随浏览器发出的建立连接的初始请求一起发送.因此,只需确保在启动任何EventSource连接之前为cookie设置了会话标识符.

You can achieve what you want by utilizing cookies, as pointed out by 4esn0k. Cookies are sent along with the initial request that the browser makes to establish the connection. So, just make sure you set the session identifier for the cookie before launching any EventSource connections.

这篇关于EventSource和基本的HTTP身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆