Repository navigation
refactor: 로그인 회원 id를 @LoginMemberId 리졸버로 받는다 - #147
Merged
Merged
Conversation
컨트롤러 20개와 Swagger 인터페이스에 Long.valueOf(jwt.getSubject())가 53번, 같은 일을 하는 private memberId(Jwt) 헬퍼가 4개 흩어져 있었다. - @LoginMemberId Long loginMemberId 파라미터로 바꾸고, 리졸버가 인증 정보의 Jwt subject를 읽는다. 비로그인 허용 엔드포인트(일별 예약)는 required = false로 null을 받는다. - 비밀번호 버전 클레임(pwv)이 필요한 초기 설정 2개 메서드만 Jwt를 함께 받는다. - 문서에는 이 파라미터를 노출하지 않는다(이전 @parameter(hidden = true)와 같은 결과).
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요약
동작을 바꾸지 않는 리팩토링. 컨트롤러 20개와 Swagger
*Api인터페이스에@AuthenticationPrincipal Jwt jwt+Long.valueOf(jwt.getSubject())가 53번, 같은 일을 하는private Long memberId(Jwt)헬퍼가 4개 흩어져 있었다.변경
auth/security/LoginMemberId(어노테이션) +LoginMemberIdArgumentResolver+global/config/WebMvcConfig(등록).@LoginMemberId Long loginMemberId—@AuthenticationPrincipal과 같이 인증 정보의 principal(Jwt)에서 subject를 읽는다. 인증이 없으면 401(AuthExceptionType.UNAUTHORIZED). 이전에는 그 경우 NPE로 500이었지만, 해당 경로는 Security에서 이미 인증을 요구하므로 실제로는 도달하지 않는다.@LoginMemberId(required = false)— 비로그인 허용인GET /v1/reservations/daily에서 null.loginMemberId로 통일했다. 경로 변수memberId를 함께 받는 메서드(부원 배정 해제 등)와 이름이 겹치지 않게 하려는 것이다.pwv)이 필요한MemberController의 초기 설정 2개 메서드만Jwt를 함께 받는다.SpringDocUtils.addAnnotationsToIgnore(LoginMemberId.class)— 문서에 요청 파라미터로 나오지 않는다(이전@Parameter(hidden = true)와 같은 결과).테스트
ApiDocsIntegrationTest:/v3/api-docs에loginMemberId·viewerMemberId·jwt파라미터가 없다. 리팩토링 전 코드에서도 통과해 문서가 바뀌지 않았음을 확인했다../gradlew test: 533건 중 532 통과, 1 스킵.