liriming
2024-11-26 5b952f77058a9da5af5e143a6c2c7ba195aa736d
提交 | 用户 | 时间
bbc1ee 1 package com.iailab.module.model.framework.security.config;
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.ExpressionUrlAuthorizationConfigurer;
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(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry) {
22                 // TODO iailab:这个每个项目都需要重复配置,得捉摸有没通用的方案
23                 // Swagger 接口文档
24                 registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据
25                         .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI
26                 // Druid 监控
27                 registry.antMatchers("/druid/**").anonymous();
28                 // Spring Boot Actuator 的安全配置
29                 registry.antMatchers("/actuator").anonymous()
30                         .antMatchers("/actuator/**").anonymous();
137356 31
32                 registry.antMatchers("/admin-api/model/pre/item/upload-model").anonymous();
bbc1ee 33                 // RPC 服务的安全配置
34                 registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll();
35             }
36
37         };
38     }
39
40 }