【问题标题】:spring boot admin 401 when service enable spring security bcryptpasswordencoder当服务启用spring security bcryptpasswordencoder时spring boot admin 401
【发布时间】:2021-01-04 10:45:59
【问题描述】:

这是 spring 安全配置

http
  .cors()
  .and()
  .csrf().disable()
  .authorizeRequests()
  .antMatchers(ignores).permitAll()
  .anyRequest().authenticated()
  .and().exceptionHandling().authenticationEntryPoint(unauthorizedHandler)
  .and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
  .and().csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
  .ignoringAntMatchers("/instances","/actuator/**");

cors 配置为允许所有区域。

  @Override
  public void addCorsMappings(CorsRegistry registry) {
    registry.addMapping("/**")
            .allowedOrigins("*")
            .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
            .maxAge(3600)
            .allowCredentials(true);
  }

如果添加以下代码,我们会在 spring boot admin 上得到 401。我需要哪里/什么配置?

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

【问题讨论】:

  • 你的调试日志告诉你什么,因为你在发帖之前显然已经检查过了?

标签: spring-security spring-boot-admin


【解决方案1】:

已修复! 只需将 spring boot admin 配置的用户添加到服务数据库即可。 但是我仍然对此感到困惑,我已经准备好将spring security配置为忽略以下路径

ignoringAntMatchers("/instances","/actuator/**");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-03
    • 2019-07-12
    • 1970-01-01
    • 2014-03-22
    • 1970-01-01
    • 2018-08-21
    • 2018-09-09
    • 2022-01-21
    相关资源
    最近更新 更多