Skip to content

Commit

Permalink
[fix] Authconfig에서passwordEncode참조 하도록 변경
Browse files Browse the repository at this point in the history
appconfig에서passwordEncode bean을 등록 하고
Authconfig 에서 passwordEncode를 참조 하도록 변경
  • Loading branch information
liyusang1 committed Jan 5, 2024
1 parent 2edf21e commit c30a849
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -14,6 +15,11 @@
@Configuration
public class AppConfig {

@Bean
public BCryptPasswordEncoder bCryptPasswordEncoder() {
return new BCryptPasswordEncoder();
}

@Bean
public ObjectMapper objectMapper() {
ObjectMapper objectMapper = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c30a849

Please sign in to comment.