Encoded password does not look like BCrypt

后端 未结 17 1862
心在旅途
心在旅途 2020-12-05 13:20

I am using Spring Boot, Spring Security, OAuth2 and JWT to authenticate my application, but I keep getting this nasty error and I don\'t have any idea what is wrong. My

相关标签:
17条回答
  • 2020-12-05 13:50
    1. In case you've added "{bcrypt}" right before password, and not configured your app accordingly, you will get this error. Consider removing this.
    2. If still not resolved, just set the column length of the user's password to 60( 68 if you've added {bcryt} at the beginning) Worked for me!
    0 讨论(0)
  • 2020-12-05 13:51

    I got rid of this error message by using a long, 60 chars+ password e.g. CXPW3XT2vXwBZk9mYZ5eCrKPM8kXJC6bbwJQjtGq2NQRYQPzsvqTwYz8JvWhWD5KLrrUHHammBNV3tkkyA4U

    0 讨论(0)
  • 2020-12-05 13:53

    For my own similar scenario I just encoded the password like this passwordEncoder().encode("password") instead of raw String "password":

    authenticationManagerBuilder
      .inMemoryAuthentication()
      .withUser("user")
      // Just changed here
      .password(passwordEncoder().encode("password"))
      .roles("USER");
    
    
    @Bean
    public PasswordEncoder passwordEncoder() {
      return new BCryptPasswordEncoder();
    }
    
    0 讨论(0)
  • 2020-12-05 13:53

    use noop in secret for tests.

    @Override
    public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
        clients.inMemory()
                .withClient("angular")
                .secret("{noop}@ngular0")
                .scopes("read", "write")
                .authorizedGrantTypes("password")
                .accessTokenValiditySeconds(1800);
    }
    
    0 讨论(0)
  • 2020-12-05 13:56

    You are likely missing this bean in your Security configuration SecurityConfig

    @Bean
    public DaoAuthenticationProvider getAuthenticationProvider() {
        DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
        authenticationProvider.setUserDetailsService(customDetailsService);
        authenticationProvider.setPasswordEncoder(encoder());
        return authenticationProvider;
    }
    
    0 讨论(0)
提交回复
热议问题