潘志宝
2024-11-11 aa1aa68141e3ee33f98cdd785ddc5c244fedc592
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.report.framework.security.config;
H 2
3 import com.iailab.framework.security.config.AuthorizeRequestsCustomizer;
4 import org.springframework.context.annotation.Bean;
5 import org.springframework.context.annotation.Configuration;
6 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
7 import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
8
9 /**
10  * Report 模块的 Security 配置
11  */
12 @Configuration("reportSecurityConfiguration")
13 public class SecurityConfiguration {
14
15     @Bean("reportAuthorizeRequestsCustomizer")
16     public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() {
17         return new AuthorizeRequestsCustomizer() {
18
19             @Override
20             public void customize(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) {
21                 // Swagger 接口文档
22                 registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据
23                         .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI
24                 // Spring Boot Actuator 的安全配置
25                 registry.antMatchers("/actuator").anonymous()
26                         .antMatchers("/actuator/**").anonymous();
27                 // Druid 监控
28                 registry.antMatchers("/druid/**").anonymous();
29                 // 积木报表
30                 registry.antMatchers("/jmreport/**").permitAll();
31             }
32
33         };
34     }
35
36 }