Spring security 服务启用spring security bcryptpasswordencoder时的spring引导管理401
这是春季安全会议Spring security 服务启用spring security bcryptpasswordencoder时的spring引导管理401,spring-security,spring-boot-admin,Spring Security,Spring Boot Admin,这是春季安全会议 http .cors() .and() .csrf().disable() .authorizeRequests() .antMatchers(ignores).permitAll() .anyRequest().authenticated() .and().exceptionHandling().authenticationEntryPoint(unauthorizedHandler) .and().sessionManagement().se
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 boot admin配置的用户添加到服务数据库。
但我仍然对此感到困惑,我已经准备好将spring安全性配置为忽略以下路径
ignoringAntMatchers("/instances","/actuator/**");
你的调试日志告诉你了什么,因为你在这里发布之前已经检查过了?