Encrypting InMemoryAuthentication passwords with Bcrypt

前端 未结 2 1457
长发绾君心
长发绾君心 2021-01-01 03:11

Before I use Bcrypt on a custom implementation of UserDetailsService, I first want to see if I can use it in an in-memory database.

package com.patrick.Secu         


        
2条回答
  •  我在风中等你
    2021-01-01 04:08

    With Spring Security 5 you can prefix password with id of selected PasswordEncoder. If you want to use plain password, then simply use {noop} prefix, this will delegate password encoder to NoOpPasswordEncoder.

    Example code:

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
       auth.inMemoryAuthentication()
              .withUser("admin").password("{noop}password").roles("ADMIN");
    }
    

提交回复
热议问题