【发布时间】:2018-04-11 09:35:11
【问题描述】:
我有一个 SpringBoot 2.0.1.RELEASE mvc 应用程序,这是我的配置文件
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private Environment env;
@Override
protected void configure(HttpSecurity http) throws Exception {
final List<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
if (activeProfiles.contains("dev")) {
http.csrf().disable();
http.headers().frameOptions().disable();
}
http
.authorizeRequests()
.antMatchers(publicMatchers()).permitAll()
.and()
.formLogin().loginPage("/login").defaultSuccessUrl("/elcordelaciutat/config")
.failureUrl("/login?error").permitAll()
.and()
.logout().permitAll();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
PasswordEncoder encoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
UserDetails userDetails = User.withUsername("elcor")
.password(encoder.encode("elcor"))
.roles("ADMIN")
.build();
auth.inMemoryAuthentication().withUser(userDetails);
}
private String[] publicMatchers() {
/** Public URLs. */
final String[] PUBLIC_MATCHERS = {
"/webjars/**",
"/css/**",
"/js/**",
"/images/**",
"/",
"/about/**",
"/contact/**",
"/error/**/*",
"/console/**"
};
return PUBLIC_MATCHERS;
}
}
但是当我登录到应用程序时,我在日志文件中收到了这条消息:
2018-04-11 11:27 [http-nio-5678-exec-7] WARN o.s.s.c.b.BCryptPasswordEncoder - Encoded password does not look like BCrypt
我无法登录...密码正确。将我的应用程序从 SpringBoot 1 更新到 SpringBoot 2 后出现此错误
【问题讨论】:
-
通过快速搜索,我找到了 this 。可能是因为更新版本的 Bcrypt 导致哈希格式发生了变化。
标签: spring spring-mvc spring-boot spring-security bcrypt