Spring Boot: How to specify the PasswordEncoder?

前端 未结 15 1206
醉梦人生
醉梦人生 2020-12-02 06:27

Currently I got the main class:

package com.recweb.springboot;

import org.springframework.boot.SpringApplication;
im         


        
15条回答
  •  余生分开走
    2020-12-02 07:11

    You need to set the password encoder like this:

    @Bean
    public PasswordEncoder passwordEncoder() {
      return PasswordEncoderFactories.createDelegatingPasswordEncoder();
    }
    

    It's required to use the passwordEncoder for the users and also for the clients in Spring Boot 2

    Check out this repository https://github.com/dzinot/spring-boot-2-oauth2-authorization-jwt

    You can see how the passwordEncoder is set up and how to use it with users and clients in the database.

提交回复
热议问题