houzhongjian
2024-12-03 874287a4c02d0a980d8b97c4a691b4f37ec5e812
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.bpm.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;
874287 7 import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer;
e7c126 8
H 9 /**
10  * Bpm 模块的 Security 配置
11  */
12 @Configuration(proxyBeanMethods = false, value = "bpmSecurityConfiguration")
13 public class SecurityConfiguration {
14
15     @Bean("bpmAuthorizeRequestsCustomizer")
16     public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() {
17         return new AuthorizeRequestsCustomizer() {
18
19             @Override
874287 20             public void customize(AuthorizeHttpRequestsConfigurer<HttpSecurity>.AuthorizationManagerRequestMatcherRegistry registry) {
e7c126 21                 // TODO iailab:这个每个项目都需要重复配置,得捉摸有没通用的方案
H 22                 // Swagger 接口文档
874287 23                 registry.requestMatchers("/v3/api-docs/**").permitAll() // 元数据
H 24                         .requestMatchers("/swagger-ui.html").permitAll(); // Swagger UI
e7c126 25                 // Druid 监控
874287 26                 registry.requestMatchers("/druid/**").anonymous();
e7c126 27                 // Spring Boot Actuator 的安全配置
874287 28                 registry.requestMatchers("/actuator").anonymous()
H 29                         .requestMatchers("/actuator/**").anonymous();
e7c126 30             }
H 31
32         };
33     }
34
35 }