[英]Enable Spring Boot 2.0 Actuator Endpoints With JWT security
First, I'm new to Spring Boot Framework. 首先,我是Spring Boot Framework的新手。 I have been working on actuator for few days now and was able to set up endpoints to monitor the system.
我已经在执行器上工作了几天,并且能够设置端点来监视系统。 How ever when I integrate JWT for the security all my actuator endpoints got broke.
为了安全起见,当我集成JWT时,我的所有执行器端点都崩溃了。
How can I disable JWT security for actuator endpoints which is on top of spring boot security? 如何在弹簧启动安全性的基础上禁用执行器端点的JWT安全性? Following is my application.yml file properties.
以下是我的application.yml文件属性。
management:
endpoint:
metrics:
enabled: true
endpoints:
web:
exposure:
include: health, metrics
If you do have dependency on Spring Security you have to configure (disable) it specifically for the /actuator
endpoints. 如果确实依赖Spring Security,则必须专门为
/actuator
端点配置(禁用)它。
You have to extend WebSecurityConfigurerAdapter
as described in the official documentation and permit all access to the desired endpoints. 您必须按照官方文档中的说明扩展
WebSecurityConfigurerAdapter
并允许所有访问所需的端点。 Check out this Spring Boot 2 Security example Disabling actuator security but not user-defined endpoints . 查看此Spring Boot 2安全性示例禁用执行器安全性,但不禁用用户定义的端点 。
This is how you can disable the security to the actuator endpoints: 这样可以禁用执行器端点的安全性:
@Configuration
public class ActuatorSecurity extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests()
.anyRequest().permitAll()
}
}
The custom security example is also useful. 定制安全性示例也很有用。
Complementing hovanessyan answer, if you are using @EnableResourceServer on your configuration, you also will need add the @Order(-1) annotation to your "ActuatorSecurity" class. 补充hovanessyan答案,如果您在配置上使用@EnableResourceServer,则还需要将@Order(-1)批注添加到“ ActuatorSecurity”类。
See more here: https://stackoverflow.com/a/50048440/9697259 在此处查看更多信息: https : //stackoverflow.com/a/50048440/9697259
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.