Java Spring消息+安全如何通过WebSocket登录?
我正在开发一个带有spring消息和STOMP over sockJs的服务器。 我想制作一个经过深思熟虑的WebSocket。 所以,我确实从客户端发送了一些令牌,然后我逐个令牌获得了针头用户,我想将我的会话与该用户关联,我接下来做了:Java Spring消息+安全如何通过WebSocket登录?,java,spring,spring-security,stomp,spring-messaging,Java,Spring,Spring Security,Stomp,Spring Messaging,我正在开发一个带有spring消息和STOMP over sockJs的服务器。 我想制作一个经过深思熟虑的WebSocket。 所以,我确实从客户端发送了一些令牌,然后我逐个令牌获得了针头用户,我想将我的会话与该用户关联,我接下来做了: private void authorizeUser(Profile profile) { SignedUser signedUser = new SignedUser(profile); List<GrantedAuthority&g
private void authorizeUser(Profile profile) {
SignedUser signedUser = new SignedUser(profile);
List<GrantedAuthority> authorities = Arrays.asList(new SimpleGrantedAuthority("ROLE_USER"));
UsernamePasswordAuthenticationToken authentication =
new UsernamePasswordAuthenticationToken(signedUser, null, authorities);
SecurityContextHolder.getContext().setAuthentication(authentication);
}
但是会话没有关联,有人能帮我解决这个问题吗
谢谢。请点击以下链接。SpringSecurity4.0允许对Web套接字提供开箱即用的支持
我试图实现,但get无法自动连接字段:private org.springframework.session.SessionRepository org.springframework.session.web.socket.config.annotation.AbstractSessionWebSocketMessageBrokerConfigure.SessionRepository;嵌套异常为org.springframework.beans.factory.NoSuchBean定义异常:没有[org.springframework.session.SessionRepository]类型的合格bean您有什么建议吗?我面临类似的问题,您如何从客户端发送令牌?