如何解决验证和识别WebSocket连接
我正在使用带有JWT和spring security的spring-boot。但是,我添加了websocket支持,无法找到方法来验证连接的身份(只有授权用户才能连接)以及如何识别连接所属的人。
在我的WebSecurity配置中,使用:
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity.csrf()
.disable()
.authorizeRequests().antMatchers("/register","/authenticate").permitAll()
.anyRequest().authenticated().and()
.exceptionHandling()
.authenticationEntryPoint(jwtAuthenticationEntryPoint)
.and()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
httpSecurity.addFilterBefore(jwtRequestFilter,UsernamePasswordAuthenticationFilter.class);
但是,据我所知,WebSockets不会在握手时传输标头,这意味着我无法使用 jwtRequestFilter来检查JWT令牌。
处理此问题的正确方法是什么?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。