【发布时间】:2020-08-05 08:33:21
【问题描述】:
我正在使用Stomp 在 Spring 和 Angular 之间实现 websocket 通信。我没有使用基于会话的身份验证,而是JWT 身份验证。我遇到了SimpMessagingTemplate.convertAndSendToUser() 方法的问题。由于我没有基于会话的身份验证,因此 Spring 不知道如何找到将 simpSessionId 与目标用户登录连接的方法。我试过这个https://github.com/spring-projects/spring-framework/blob/master/src/docs/asciidoc/web/websocket.adoc#token-authentication 添加Authorization 标头,但我不能,因为它是Http 标头,而不是websocket。如何准备我的后端和前端应用程序以启用convertAndSendToUser() 机制?如何在建立 websocket 连接时传递Authorization 标头?我在Stackoverflow 上检查了几个主题,但实际上没有一个是解决方案。
【问题讨论】:
标签: angular spring websocket jwt stomp