Pitfalls encountered in Spring Security

**

Pitfalls encountered in Spring Security

**
1. Console warning: There is no PasswordEncoder mapped for the id "null"
solution:

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

Insert picture description here
2. The console warns: Encoded password does not look like BCrypt, and an error is reported when the correct password is entered. It is puzzled. Change
the encryption method to:

public PasswordEncoder passwordEncoder() {
    
    
    return NoOpPasswordEncoder.getInstance();
}

I don't know why, so that's it. Watching the video to learn, according to knocking others can but I can not.
Another solution is to change the encryption method back to 1, and then encrypt
secret(passwordEncoder.encode("SECRET")) to the decryption key of jwt

public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
    
    
    clients
            .inMemory()
            .withClient("clientapp")
            .authorizedGrantTypes("password","refresh_token")
            .authorities("USER")
            .scopes("read", "write")
            .resourceIds(RESOURCE_ID)
            .secret(passwordEncoder.encode("SECRET"));
}

You can refer to this article: Link: https://stackoverflow.com/questions/49582971/encoded-password-does-not-look-like-bcrypt

Guess you like

Origin blog.csdn.net/weixin_44379187/article/details/106987474