CustomUserDetailsService
페이지 정보
본문
package web.security;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
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;
import org.springframework.stereotype.Service;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
@Log4j2
@Service
//@RequiredArgsConstructor
public class CustomUserDetailsService implements UserDetailsService {
private PasswordEncoder passwordEncoder;
public CustomUserDetailsService() {
this.passwordEncoder = new BCryptPasswordEncoder();
}
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
log.info("loadUserByUsername : "+ username);
UserDetails userDetails = User.builder()
.username("user1")
//.password("1111")
.password(passwordEncoder.encode("1111")) //패스워드 인코딩 필요
.authorities("ROLE_USER")
.build();
return userDetails;
}
}
- 이전글CustomSecurityConfig 24.07.18
- 다음글/login ( 브라우저 주소 실행 ) 24.07.18
댓글목록
등록된 댓글이 없습니다.