fix: 修改health包名。
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package com.intc.config;
|
||||
|
||||
import com.intc.common.core.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
/**
|
||||
* @ClassName ActuatorSecurityConfig
|
||||
* @Author YaphetS
|
||||
* @Date 2023/3/14 9:18
|
||||
* @Version 1.0
|
||||
* @Description TODO
|
||||
*/
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
public class ActuatorSecurityConfig {
|
||||
|
||||
@Autowired
|
||||
Environment env;
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
String contextPath = env.getProperty("management.endpoints.web.base-path");
|
||||
if(StringUtils.isEmpty(contextPath)) {
|
||||
contextPath = "/actuator";
|
||||
}
|
||||
http.csrf().disable();
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/**"+contextPath+"/**")
|
||||
.authenticated()
|
||||
.anyRequest()
|
||||
.permitAll()
|
||||
.and()
|
||||
.httpBasic();
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user