Skip to content

AbstractAuthenticationProcessingFilter 구현 메서드에 관한 질문 #17

Answered by seonpilKim
dongkyunkimdev asked this question in Q&A
Discussion options

You must be logged in to vote

1. requiresAuthentication를 override 한 이유

먼저 의도를 설명드리자면, 다른 이유가 있다기 보다는 단순히 커스텀 matcher를 사용해서 인증 필터를 건너뛸 paths를 비교하는 메소드가 requiresAuthentication()이라서 재정의하려는 생각으로 구현 했던 것 같습니다.

그리고 동균님께서 지적해 주신 김에 코드를 다시 살펴봤는데, 리팩토링을 고려할 만한 부분을 찾은 것 같아서 두 분의 의견을 한 번 여쭤보고 싶습니다..!

우선, 생성자 JwtAuthenticationFilter() 에서 다른 부모 생성자를 호출하게 되면 requiresAuthentication() 메소드를 굳이 재정의 할 필요가 없어질 것 같습니다.

// AbstractAuthenticationProcessingFilter.java
protected AbstractAuthenticationProcessingFilter(RequestMatcher requiresAuthenticationRequestMatcher) {
     Assert.notNull(requiresAuthenticationRequestMatcher, "requiresAuthenticationRequestMatcher cannot be null");
    this.requiresAuthenticationRequestMatcher = requiresAuth…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@dongkyunkimdev
Comment options

dongkyunkimdev Jun 17, 2022
Collaborator Author

Comment options

You must be logged in to vote
4 replies
@slolee
Comment options

slolee Jun 16, 2022
Collaborator

@slolee
Comment options

slolee Jun 16, 2022
Collaborator

@dongkyunkimdev
Comment options

dongkyunkimdev Jun 17, 2022
Collaborator Author

@seonpilKim
Comment options

Answer selected by dongkyunkimdev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
🙋‍♂️ QnA 질문과 답변
3 participants