Spring Security Oauth2.0 报错java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id “null”

  • A+
所属分类:Spring Security

Spring Security Oauth2.0 报错java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id "null"

原因:认证server里的auth.inMemoryAuthentication()里的密码不能直接写,需要加上BCryptPasswordEncoder的encode处理。修正后如下:

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
//        auth.parentAuthenticationManager(authenticationManager)
        auth.inMemoryAuthentication()
                .withUser("john").password(passwordEncoder().encode("123")).roles("USER");
    }

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

 

 

ZPY

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: