개발/Java,Spring

Spring boot 2.4.5 @AuthenticationPrincipal occurs null

호돌맨 2021. 4. 30. 15:07

문제

Spring boot 2.4.5로 업그레이드 한 뒤 authentication 값이 null이다.

@GetMapping("/api/users/me")
public UserResponse getMe(@AuthenticationPrincipal Authentication authentication) {
    // ...
    // ...
}

해결

PrincipalMethodArgumentResolver를 추가해도 되지만
그냥 @AuthenticationPrincipal annotation을 제거하면 된다.
스프링에서 문서 수정하는걸 깜빡 했나보다.

이슈 링크

이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.