Configure security for Spring Boot 2.0 acuator framework(为Spring Boot 2.0仿真器框架配置安全性)
问题描述
我想在我的Spring Boot 2.0应用程序中使用Spring Actuator框架。框架本身按照预期工作,因此我能够到达例如我的/actuator/health终结点。在那里,我呈现了一个登录对话框。我想摆脱它,并尝试了以下方法:
@Configuration
@EnableWebFluxSecurity
public class SecurityConfiguration {
@Bean
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
return http
.authorizeExchange()
.matchers(EndpointRequest.to("prometheus")).permitAll()
.matchers(EndpointRequest.toAnyEndpoint()).authenticated()
.anyExchange().permitAll()
.and()
.formLogin()
.and()
.httpBasic()
.and()
.build();
}
但是,在应用程序启动期间,我收到以下错误:
未能实例化[org.springframework.security.web.server.SecurityWebFilterChain]:工厂方法‘securityWebFilterChain’引发异常;嵌套异常为java.lang.IlLegalArgumentException:身份验证管理器不能为空
当然,我试图搜索它,但我总是只能得到描述使用Spring Boot 1.x框架的不同场景或安全配置的页面。有人能帮我一下吗?
推荐答案
最简单的方法应该是让SecurityConfiguration扩展WebSecurityConfigurerAdapter并覆盖configure(WebSecurity web),如下所示:
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring()
.antMatchers("/actuator/**");
}
// ...
}
另外,我不熟悉@EnableWebFluxSecurity,但要使上面的内容正常工作,您需要同时使用@Configuration和@EnableWebSecurity注释。
SecurityWebFilterChain。
这篇关于为Spring Boot 2.0仿真器框架配置安全性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为Spring Boot 2.0仿真器框架配置安全性
基础教程推荐
- 在springboot中如何给mybatis加拦截器 2023-04-29
- JPA惰性列表上的流 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
