Spring/Spring Security

[Spring Security] UserDetails / UserDetailsService

고해주 2023. 1. 31. 17:04

UserDetails

 

● Spring Security에서 사용자의 정보를 담는 인터페이스

 

 

 

 

 

UserDetailsService

 사용자 정보를 가져오는 인터페이스 

 

● 기본 메소드

loadUserByUsername() 메소드를 오버라이딩

package org.springframework.security.core.userdetails;

public interface UserDetailsService {
    UserDetails loadUserByUsername(String username) throws UsernameNotFoundException;
}

 

 

 

 

UsernameNotFoundException

● UserDetailService구현이 사용자 이름으로 찾을 수 없는 경우 발생하는 exception

UsernameNotFoundException(String msg, Throwable cause)

- msg : 상세메시지

- cause : 근본 원인

'Spring > Spring Security' 카테고리의 다른 글

[Spring Security] Form Login  (0) 2023.02.03
[Spring Security] Spring Security  (0) 2023.01.31