Azure APIM 和 Websocket JWT 验证
我设置了一个 Azure API 管理 (APIM)(基本)服务,通过 validate-jwt 通过 HTTP 查询连接对我的 JWT 令牌进行身份验证插件,效果很好。我想使用 APIM 上的 WebSocket 连接进行相同的 JWT 令牌验证。
我可以使用 websockets 获得的最好效果是典型的订阅密钥查询字符串验证。在读到 WebSocket 客户端(如 Apollo 的 WebSocketLink)只允许查询字符串参数而不是标头修改(可能是由于浏览器限制?)后,我尝试传递一个“授权”查询字符串对,但 validate-jwt 似乎也误读了这一点(websocket连接失败)。
Microsoft 似乎确实在文档网站上宣传 JWT 验证(https: //learn.microsoft.com/en-us/azure/api-management/websocket-api) 但我找不到一个明确的例子来说明它是如何工作的。
有什么建议(特别是如果你已经让它发挥作用的话)?谢谢!
I have an Azure API Management (APIM) (Basic) service set up to authenticate my JWT tokens over HTTP query connections via the validate-jwt plugin, and that works fine. I would like to do the same JWT token validation using a WebSocket connection over APIM.
The best I can get with websockets is the typical subscription-key querystring validation. After reading that WebSocket clients (like Apollo's WebSocketLink) only allow query string params as opposed to header modifications (potential due to Browser restrictions?), I tried passing an "authorization" query string pair in, but validate-jwt seems to misread that too (the websocket connection fails).
Microsoft does appear to advertise JWT validation on the docs website (https://learn.microsoft.com/en-us/azure/api-management/websocket-api)
but I can't find a clear example to show how that's expected to work.
Any suggestions (especially if you've gotten this to work)? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在握手操作中按如下方式使用它,但是一旦握手完成,http 请求就会升级为 WebSocket,因此在 Web 套接字连接期间不再执行该操作。
https://learn. microsoft.com/en-us/azure/api-management/api-management-access-restriction-policies#ValidateJWT
You can use it as below in the handshake operation but once the handshake is done the http request is upgraded to WebSocket so the operation is no longer executed during the web socket connection.
https://learn.microsoft.com/en-us/azure/api-management/api-management-access-restriction-policies#ValidateJWT