@AuthenticationPrincipal 사용
Spring Security에서 인증된 사용자 정보를 가져오는 방법으로 자주 사용되는 @AuthenticationPrincipal에 대해서 알아보겠습니다. 이 글에서는 다음과 같은 환경을 가정합니다.JWT 기반 인증 방식 사용OncePerRequestFilter를 상속한 JWT 검증 필터 구현UserDetails를 구현한 커스텀 클래스(CustomUserDetails) 사용Spring Security의 구조SecurityContextHolder └─ SecurityContext └─ Authentication ├─ Principal (사용자 정보 객체, 보통 UserDetails 구현체) ├─ Credentials (자..
2025.01.07