How to use Spring security without password encoding?

前端 未结 4 2558
误落风尘
误落风尘 2021-02-20 10:49

I\'m trying to learn Spring security currently. I used BCryptPasswordEncoder to encode user password before persisting into a database

Code:



        
4条回答
  •  感情败类
    2021-02-20 11:23

    Maybe you can implement this simple code to evade Spring Encoder

    public class PasswordEnconderTest implements PasswordEncoder {
        @Override
        public String encode(CharSequence charSequence) {
            return charSequence.toString();
        }
    
        @Override
        public boolean matches(CharSequence charSequence, String s) {
            return charSequence.toString().equals(s);
        }
    }
    

    and add in your WebSecurityConfig:

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

    it's not recommended but you can implement

提交回复
热议问题