鞍钢鲅鱼圈能源管控系统后端代码
houzhongjian
2024-12-26 07073fa5e1e14b1f9d5d4f3253d9403ab311ae3c
提交 | 用户 | 时间
07073f 1 package com.iailab.module.ansteel.framework.security.config;
H 2
3 import com.iailab.framework.security.config.AuthorizeRequestsCustomizer;
4 import com.iailab.module.system.enums.ApiConstants;
5 import org.springframework.context.annotation.Bean;
6 import org.springframework.context.annotation.Configuration;
7 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
8 import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer;
9
10 /**
11  * System 模块的 Security 配置
12  */
13 @Configuration(proxyBeanMethods = false, value = "systemSecurityConfiguration")
14 public class SecurityConfiguration {
15
16     @Bean("systemAuthorizeRequestsCustomizer")
17     public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() {
18         return new AuthorizeRequestsCustomizer() {
19
20             @Override
21             public void customize(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry registry) {
22                 // TODO iailab:这个每个项目都需要重复配置,得捉摸有没通用的方案
23                 // Swagger 接口文档
24                 registry.requestMatchers("/v3/api-docs/**").permitAll() // 元数据
25                         .requestMatchers("/swagger-ui.html").permitAll(); // Swagger UI
26                 // Druid 监控
27                 registry.requestMatchers("/druid/**").anonymous();
28                 // Spring Boot Actuator 的安全配置
29                 registry.requestMatchers("/actuator").anonymous()
30                         .requestMatchers("/actuator/**").anonymous();
31                 // RPC 服务的安全配置
32                 registry.requestMatchers(ApiConstants.PREFIX + "/**").permitAll();
33             }
34
35         };
36     }
37
38 }