[Feat/#113] JWT 토큰 인증 로직 개선 #114
Open
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.
🚩 관련 이슈
📋 구현 기능 명세
📌 PR Point
현재 로직에서는
jwt 필터에서tokenProvider.getAuthentication(token)으로Authentication객체 반환 ->getAuthentication함수 내부적으로는 token에서 이메일과 멤버타입 정보를 가지고 DB에서 member 객체를 조회하여PrincipalDetails저장함현재 로직은 모든 api가 jwt 필터를 지나면서 매번 DB를 조회한다. -> 사용자가 많으면 DB 부하 증가
-> JWT의 장점 중 하나는 클라이언트가 전달하는 토큰 자체에 사용자 정보를 포함하고 있어 서버가 상태를 저장할 필요가 없다는 것인데, 이 코드에서는 매 요청마다 DB에서 사용자 정보를 조회하고 있다. (사용자 정보를 조회하지않아도 되는 api도 무조건 조회되고 있음)
getMember 대신 모두 memberId로 변경했는데 혹시 중간에 이상하게 변경한 부분이 있는지,,, 너무 많아서 실수 있을까봐 두렵다...
거의 지금 대부분이 member 별로 조회할때 member 객체 기준으로 조회하는데 memberId를 기준으로 검색한다면 굳이 memberService에서 member를 찾고 또 조회할필요가 없을 것 같습니다! 나중에 이것도 수정하면 좋을거같아요~~
🛠️ 테스트