如何解决当服务启用 spring 安全 bcryptpasswordencoder 时,spring boot admin 401
这是 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 boot admin 配置的用户添加到服务数据库。 但是我还是很困惑,我都准备好了配置spring security忽略下面的路径
ignoringAntMatchers("/instances","/actuator/**");
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。