-
Notifications
You must be signed in to change notification settings - Fork 8
refactor: auth type 추가, 로그아웃 필터 로직 변경 #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Gyuhyeok99
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
한 가지 궁금한 점만 코멘트 남겨놨습니다! 코드가 아주 잘이해되네요 고생하셨습니다! 그동안 전 필터를 제대로 이해 못한 채 썼었는데 되돌아보게 되네요 😂.. 👍
| public void customCommence(HttpServletResponse response, CustomException customException) throws IOException { | ||
| SecurityContextHolder.clearContext(); | ||
| ErrorResponse errorResponse = new ErrorResponse(customException); | ||
| writeResponse(response, errorResponse); | ||
| } | ||
|
|
||
| public void customCommence(HttpServletResponse response, CustomException customException) throws IOException { | ||
| ErrorResponse errorResponse = new ErrorResponse(customException); | ||
| public void generalCommence(HttpServletResponse response, Exception exception) throws IOException { | ||
| SecurityContextHolder.clearContext(); | ||
| ErrorResponse errorResponse = new ErrorResponse(AUTHENTICATION_FAILED, exception.getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게 CustomException예외와 일반 예외를 한 필터에서 관리하니 훨씬 좋은 거 같습니다! 한 가지 궁금한 점이 있는데 예외 발생시마다SecurityContextHolder.clearContext()를 호출해야하는 이유가 혹시 무엇인지 알 수 있을까요? 저는 보통 토큰 만료나 로그아웃 등의 인증 관련 상황에서만 호출했어서 궁금해서 여쭤봅니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Authentication 이 불완전한 상태로 저장되는 것을 막기 위해 그렇게 했습니다.
예를 들어 [A 필터에서 정상 저장됨 -> B 필터에서 예외 발생] 의 경우, 이전에 저장된 것을 지워주는게 안전하다 생각해서요 😊
관련 이슈
작업 내용
다양한 인증 방식 추가 / 로그아웃 필터 로직 변경을 구현했습니다.
특이 사항
전체적으로 다 구현하긴 했지만, 순차적으로 적용할 거 적용하면서 머지하는게 좋을 것 같아서나눠 올립니다.
앞으로 올라올 PR들이 어떻게 진행될지 궁금하시다면..
여기에서 볼 수 있습니다.
리뷰 요구사항 (선택)
커밋 따라가며 읽으면 리뷰하기 편하실거예요~