【问题标题】:Spring boot security - ActuatorSpring Boot 安全性 - 执行器
【发布时间】:2020-01-03 13:02:07
【问题描述】:

我正在尝试将我的应用程序配置为始终公开执行器端点,如果配置设置为需要安全性,则将其应用于我的端点以进行 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() 管理

【问题讨论】:

    标签: spring spring-boot spring-security spring-boot-actuator spring-boot-admin


    【解决方案1】:

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

    @Override
    protected void configure(HttpSecurity http) throws Exception {
    
    http.authorizeRequests().antMatchers("/health", "/actuator/**").permitAll();
    
    if (authenticationRequired) {
        http.authorizeRequests().antMatchers("/**").authenticated().and().httpBasic();
    }
    }
    

    我错过了一个前导/

    【讨论】:

      猜你喜欢
      • 2016-08-26
      • 1970-01-01
      • 2016-02-10
      • 1970-01-01
      • 2018-02-27
      • 2018-09-11
      • 2021-07-14
      • 2016-05-14
      • 2017-07-02
      相关资源
      最近更新 更多