大佬教程收集整理的这篇文章主要介绍了Spring Boot Actuator-无法禁用/ info端点,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
最后,我设法解决了我的问题。我仅在执行器中启用了/ info和/ health端点。为了只允许具有admin角色的用户访问/ info端点,我需要混合执行器管理安全性和spring安全性配置。
endpoints.enabled: false
endpoints:
info.enabled: true
health.enabled: true
management.security.role: admin
像这样的spring安全配置(我需要更改 @H_102_5@managementSecurityConfig的 顺序以具有更高的优先级):
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = truE)
public class SecurityConfiguration {
@Configuration
protected static class AuthenticationSecurity extends GlobalAuthenticationConfigurerAdapter {
@autowired
private AuthenticationProvIDer authenticationProvIDer;
public AuthenticationSecurity() {
super();
}
@OverrIDe
public voID init(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("admin").password("secret").roles("admin");
}
}
@Configuration
@Order(ordered.HIGHEST_PRECEDENCE + 2)
public static class ManagementSecurityConfig extends WebSecurityConfigurerAdapter {
@OverrIDe
protected voID configure(httpSecurity http) throws Exception {
http.csrf().disable()
.requestMatchers()
.antMatchers("/info/**")
.and()
.authorizerequests()
.anyrequest().hasRole("admin")
.and()
.httpBasic();
}
}
@Configuration
public static class APIWebSecurityConfigurationAdapter extends WebSecurityConfigurerAdapter {
protected voID configure(httpSecurity http) throws Exception {
// API security configuration
}
}
}
我尝试在application.yml
配置文件中为生产环境禁用所有执行器端点:
endpoints.enabled: false
它适用于/ info以外的所有端点。如何关闭给定环境的所有端点?
更新:
我正在从事的项目也担任Eureka客户。在Spring Cloud Netflix的文档的“ 状态页和运行状况指示器”部分
(http://cloud.spring.io/spring-cloud-netflix/spring-cloud-
netflix.html)中,它说“ Eureka实例默认为” / info”和“ /健康”分别。
有什么解决方案可以禁用这些端点吗?
我可以使用禁用 / health 端点endpoints.enabled: false
,但不能禁用 / info 端点。
以上是大佬教程为你收集整理的Spring Boot Actuator-无法禁用/ info端点全部内容,希望文章能够帮你解决Spring Boot Actuator-无法禁用/ info端点所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。