'Spring Security 5 sha256 encoder
I have a problem with Spring Security 5 Basic authentication. I've configured Spring like this:
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// auth.inMemoryAuthentication().withUser("user").password("{noop}password").roles("ADMIN");
auth.inMemoryAuthentication().withUser("user").password("{sha256}5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8").roles("ADMIN");
}
}
Everything works great with {noop} password encoder (commented code) - I'm able to authenticate with header: Authorization: Basic dXNlcjpwYXNzd29yZA==. But when I provide sha256 encoded password (uncommented code), I keep getting:
org.springframework.security.authentication.BadCredentialsException: Bad credentials
Solution 1:[1]
Try
{SHA-256}
instead of
{SHA256}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Matmok |