首页 > 解决方案 > Spring Boot 安全性 - 执行器

问题描述

我正在尝试将我的应用程序配置为始终公开执行器端点,如果将配置设置为需要安全性,则将其应用于我的端点以进行 websocket 连接

就目前而言,我的印象是蚂蚁匹配器按顺序匹配 - 这意味着

@Override
protected void configure(HttpSecurity http) throws Exception {

http.authorizeRequests().antMatchers("/health", "/actuator", "actuator/health").permitAll();

if (authenticationRequired) {
    http.authorizeRequests().antMatchers("/**").authenticated().and().httpBasic();
}
}

上述代码应始终允许执行器端点

然而似乎事实并非如此。请有人帮助描述我的方法有什么问题。

/health/actuator我来说应该由permitAll()

标签: springspring-bootspring-securityspring-boot-actuatorspring-boot-admin

解决方案


我使用以下匹配器修复了这个问题

@Override
protected void configure(HttpSecurity http) throws Exception {

http.authorizeRequests().antMatchers("/health", "/actuator/**").permitAll();

if (authenticationRequired) {
    http.authorizeRequests().antMatchers("/**").authenticated().and().httpBasic();
}
}

我错过了一个领先的/


推荐阅读