英文:
Is there a Golang Websocket library that would let me modify the initial request / let me pick the http.Client?
问题
我想连接到一个WebSocket服务器,但该端点是Kerberos身份验证的。我有一个能够进行Kerberos身份验证的库,还有一个http.Client包装器,可以对发送到任何端点的所有请求进行身份验证。
然而,我的这两个工具似乎对gorilla/websocket没有用处。我尝试了一些方法,包括发送一个经过身份验证的GET请求,然后将响应头传递给websocket.DefaultDialer.Dial(),但这并不起作用,因为实际的握手请求本身并没有经过身份验证。
因此,我感到困惑。有人有关于如何完成这个任务的想法吗?
英文:
I want to connect to a websocket server, but the endpoint is Kerberos authenticated. I have a library that is able to Kerberos authenticate requests, and I also have an http.Client wrapper that authenticates all requests sent through it to whatever endpoint.
Neither of my tools seem to be of any use with gorilla/websocket. I've tried a few things, including sending an authenticated GET request, then passing the response headers into websocket.DefaultDialer.Dial(), but that doesn't work since the actual handshake request itself isn't authenticated.
Hence, I am perplexed. Does anyone have ideas on how this can be done?
答案1
得分: 1
我弄清楚了。这是我所做的:
- 我向服务器发送一个经过Kerberos身份验证的GET请求,请求的目标是任何经过身份验证的端点。
- 然后我对响应进行身份验证并获取Cookie。
- 我创建一个经过Kerberos身份验证的GET请求,目标是websocket端点,并将Cookie添加到请求头中。
- 然后我通过gorilla/websocket进行拨号。
问题出在对Cookie的处理上。我将答案留在这里,以防其他人在使用Kerberos或其他身份验证服务时遇到类似的问题。
英文:
I figured it out. Here is what I do:
- I send a Kerberos-authenticated GET request to any authenticated endpoint on the server.
- I then authenticate the Response and grab the Cookie.
- I create a Kerberos-authenticated GET request to the websocket endpoint and add the Cookie to its header.
- Then I dial via gorilla/websocket
The issue was the treatment of the cookie. Leaving the answer here in case people run into similar troubles with Kerberos or other auth services.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论