Skip to content

Conversation

@sejoon00
Copy link
Contributor

🌱 관련 이슈

📌 작업 내용 및 특이사항

  • Controller에서 SecurityContextHolder에 있는 인증 객체를 가져오는 커스텀 어노테이션 @authuser을 추가했습니다.
  • HandlerMethodArgumentResolver 를 구현한 AuthenticationArgumentResolver를 구현하여 Controller 단에서 SecurityContextHolder에서 인증객체를 가져오는 로직을 구현하였습니다.

📝 테스트사항

image
  • mockMvc를 통해 jwt 토큰에서 알맞은 member 객체를 불러올 수 있는지 통합테스트 하였습니다.

📚 기타

  • Spring Security에서 지원하는 @AuthenticationPrincipal 이 있지만 jwtFilter를 거치지 않는, 즉 인증이 필요하지 않는 요청에서 개발자 실수로 해당 어노테이션을 사용했을 때 NullPointerException이 터지는 문제가 있습니다.

  • image

  • 위와같이 매번 null 체크를 하는 것은 비효율적이라고 생각하여 직업 custom resovler를 구현하였습니다.

주의

@sejoon00 sejoon00 self-assigned this Jan 24, 2025
@sejoon00 sejoon00 requested a review from seokbeom00 January 24, 2025 11:36
@sejoon00 sejoon00 added For: API [이슈 대상] 외부 API Type: Feature [이슈 목적] 새로운 기능 추가 labels Jan 24, 2025
Copy link
Contributor

@seokbeom00 seokbeom00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

너무 고생하셨습니다! 커스텀 어노테이션 참 편리한것 같아요.

@sejoon00 sejoon00 changed the base branch from document/#15 to develop January 28, 2025 08:18
@sejoon00 sejoon00 merged commit 1b714ff into develop Jan 28, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For: API [이슈 대상] 외부 API Type: Feature [이슈 목적] 새로운 기능 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ 사용자 내정보 조회 api 추가합니다.

3 participants