Open
Conversation
📝 Walkthrough개요JwtAuthenticationFilter에 permitAllMatchers 기반의 사전 필터 스킵 메커니즘을 도입하여 인증 우회 경로를 중앙집중식으로 관리합니다. shouldNotFilter 메서드를 재정의하여 특정 경로에 대한 필터 로직 실행을 단축시킵니다. 변경사항
시퀀스 다이어그램sequenceDiagram
participant Client
participant Filter as JwtAuthenticationFilter
participant Matcher as permitAllMatchers
participant Chain as FilterChain
Client->>Filter: HTTP 요청
Filter->>Filter: shouldNotFilter() 호출
alt 요청이 permitAllMatchers 매치
Filter->>Matcher: 경로 패턴 확인
Matcher-->>Filter: true (우회 경로)
Filter->>Chain: doFilter 스킵, 다음 필터로 진행
Chain-->>Client: 응답 (인증 검사 없음)
else 요청이 보호 경로
Matcher-->>Filter: false (인증 필요)
Filter->>Filter: JWT 토큰 검증
alt 토큰 유효
Filter->>Chain: 인증 정보 설정 후 진행
Chain-->>Client: 응답 (성공)
else 토큰 무효/만료
Filter-->>Client: 401 Unauthorized
end
end
예상 코드 리뷰 소요 시간🎯 2 (Simple) | ⏱️ ~12분
시
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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.
🚀 작업 내용
인증이 필요없는 GET api/clubs 같은 경로에도 JWT필터가 적용되어 401 응답이 던져지는 문제를 해결했습니다.
인증 및 인가가 필요한 경로를 명확하게 하고, 필요없는 경우는 필터가 적용되지 않도록 수정했습니다.
인증이 필요없는 경로는 shouldNotFilter 메소드를 오버라이드해서 제외하도록 했습니다.
⏱️ 소요 시간
1h 30m
🤔 고민했던 내용
필터 사이의 우선순위 및 왔다갔다(?) 를 명확하게 이해하지 못해 발생한 문제였습니다.
요청 -> JwtAuthenticationFilter의 doFilterInternal(인증) -> SecurityConfig의 filterChain의 authorizeHttpRequests(인가) -> 컨트롤러
💬 리뷰 중점사항
인증 및 인가가 필요없는 API 경로가 커버되지 않은게 있다면 말씀해주세요.
추가로 해당 작업 내용은 일반적인 사용자 흐름에서 발생하는 에러는 아닙니다.
저희가 서버를 껐다가 키는 경우 브라우저의 로컬스토리지에 액세스토큰이 남아있어서 생긴 문제였는데
(서버 재시작하면서 액세스토큰을 검증하는 키가 바뀌기 때문 등)
일반적인 사용자 흐름에서 로컬스토리지에 액세스토큰이 남아있는 경우는 쉽게 생기지 않을 거 같습니다.
하지만 아무래도 지금 평가기간이다 보니 해당 PR이 머지 되었을때 문제가 생길까봐 두렵긴하네요.
큰 작업 내용은 없어서 지장이 크진 않을 거 같은데 불안하시면 일단 읽어보시고 Merge는 평가 이후 진행해주셔도 좋습니다.