Bcrypt Custom password configuration

前端 未结 2 995
南方客
南方客 2021-01-29 10:37

i am changing the password and then forwarding to /loginuser and redirect to users dashboard. i had secured this with httpbasic authentication since i am a beginner, I am using

相关标签:
2条回答
  • 2021-01-29 11:30
    @Autowired
        DataSource dataSource;
    
        @Bean
        public PasswordEncoder passwordEncoder()
        {
            return new BCryptPasswordEncoder();
        }
    
        @Override
        protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    
            auth.jdbcAuthentication().dataSource(dataSource).passwordEncoder(passwordEncoder());
        }
    
    0 讨论(0)
  • 2021-01-29 11:33

    I think you have a problem because your encoded password has a length < 28, from spring sources:

    if (saltLength < 28) {
                throw new IllegalArgumentException("Invalid salt");
    }
    

    how to fix that:

    1. Increase salt rounds to 10
    2. Try to set minimum password length to 4-5

    I hope that helps.

    0 讨论(0)
提交回复
热议问题