houzhongjian
2024-12-03 874287a4c02d0a980d8b97c4a691b4f37ec5e812
提交 | 用户 | 时间
e7c126 1 package com.iailab.framework.websocket.core.security;
H 2
3 import com.iailab.framework.security.config.AuthorizeRequestsCustomizer;
4 import com.iailab.framework.websocket.config.WebSocketProperties;
5 import lombok.RequiredArgsConstructor;
6 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
874287 7 import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer;
e7c126 8
H 9 /**
10  * WebSocket 的权限自定义
11  *
12  * @author iailab
13  */
14 @RequiredArgsConstructor
15 public class WebSocketAuthorizeRequestsCustomizer extends AuthorizeRequestsCustomizer {
16
17     private final WebSocketProperties webSocketProperties;
18
19     @Override
874287 20     public void customize(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry registry) {
H 21         registry.requestMatchers(webSocketProperties.getPath()).permitAll();
e7c126 22     }
H 23
24 }