Skip to content

Conversation

@nayonsoso
Copy link
Collaborator

@nayonsoso nayonsoso commented Jan 27, 2025

관련 이슈

작업 내용

다양한 인증 방식 추가 / 로그아웃 필터 로직 변경을 구현했습니다.

특이 사항

전체적으로 다 구현하긴 했지만, 순차적으로 적용할 거 적용하면서 머지하는게 좋을 것 같아서나눠 올립니다.
앞으로 올라올 PR들이 어떻게 진행될지 궁금하시다면..
여기에서 볼 수 있습니다.

리뷰 요구사항 (선택)

커밋 따라가며 읽으면 리뷰하기 편하실거예요~

@nayonsoso nayonsoso requested a review from Gyuhyeok99 January 27, 2025 02:56
@nayonsoso nayonsoso self-assigned this Jan 27, 2025
Copy link
Contributor

@Gyuhyeok99 Gyuhyeok99 left a comment

Choose a reason for hiding this comment

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

한 가지 궁금한 점만 코멘트 남겨놨습니다! 코드가 아주 잘이해되네요 고생하셨습니다! 그동안 전 필터를 제대로 이해 못한 채 썼었는데 되돌아보게 되네요 😂.. 👍

Comment on lines +39 to +47
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());
Copy link
Contributor

Choose a reason for hiding this comment

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

이렇게 CustomException예외와 일반 예외를 한 필터에서 관리하니 훨씬 좋은 거 같습니다! 한 가지 궁금한 점이 있는데 예외 발생시마다SecurityContextHolder.clearContext()를 호출해야하는 이유가 혹시 무엇인지 알 수 있을까요? 저는 보통 토큰 만료나 로그아웃 등의 인증 관련 상황에서만 호출했어서 궁금해서 여쭤봅니다!

Copy link
Collaborator Author

@nayonsoso nayonsoso Jan 27, 2025

Choose a reason for hiding this comment

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

Authentication 이 불완전한 상태로 저장되는 것을 막기 위해 그렇게 했습니다.
예를 들어 [A 필터에서 정상 저장됨 -> B 필터에서 예외 발생] 의 경우, 이전에 저장된 것을 지워주는게 안전하다 생각해서요 😊

@nayonsoso nayonsoso merged commit f26e75c into main Jan 27, 2025
@nayonsoso nayonsoso deleted the refactor/163-add-auth-type branch February 15, 2025 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: 다양한 인증 방식이 적용되도록 siteUser 컬럼 변경

3 participants