潘志宝
2024-11-21 d338b50afd6504a9676f0a26b3ecbcc844483e7c
提交 | 用户 | 时间
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;
7 import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
8
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
20     public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) {
21         registry.antMatchers(webSocketProperties.getPath()).permitAll();
22     }
23
24 }