diff --git a/src/main/java/com/haejwo/tripcometrue/global/config/AppConfig.java b/src/main/java/com/haejwo/tripcometrue/global/config/AppConfig.java index 1a9ee2c3..90532544 100644 --- a/src/main/java/com/haejwo/tripcometrue/global/config/AppConfig.java +++ b/src/main/java/com/haejwo/tripcometrue/global/config/AppConfig.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; /** * @author liyusang1 @@ -14,6 +15,11 @@ @Configuration public class AppConfig { + @Bean + public BCryptPasswordEncoder bCryptPasswordEncoder() { + return new BCryptPasswordEncoder(); + } + @Bean public ObjectMapper objectMapper() { ObjectMapper objectMapper = new ObjectMapper(); diff --git a/src/main/java/com/haejwo/tripcometrue/global/springsecurity/AuthConfig.java b/src/main/java/com/haejwo/tripcometrue/global/springsecurity/AuthConfig.java index 6cb472e5..7bc32a26 100644 --- a/src/main/java/com/haejwo/tripcometrue/global/springsecurity/AuthConfig.java +++ b/src/main/java/com/haejwo/tripcometrue/global/springsecurity/AuthConfig.java @@ -2,6 +2,7 @@ import com.haejwo.tripcometrue.domain.member.repository.MemberRepository; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.domain.AuditorAware; @@ -11,7 +12,6 @@ import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; @Configuration @@ -44,9 +44,13 @@ public AuthenticationManager authenticationManager(AuthenticationConfiguration c return config.getAuthenticationManager(); } + // AppConfig에서 정의한 PasswordEncoder 빈을 참조 + @Autowired + private PasswordEncoder passwordEncoder; + @Bean public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); + return passwordEncoder; } private PrincipalDetails loadUserByUsername(String email) {