-
Notifications
You must be signed in to change notification settings - Fork 0
토큰 리프레시 API 접근 시 JWT 필터를 거치지 않도록 수정 #111
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
Walkthrough이 변경 사항은 보안 구성에서 특정 엔드포인트의 permitAll 규칙을 제거하고, 예외 처리기를 확장하여 누락된 헤더 및 쿠키에 대한 처리를 추가하며, JWT 인증 필터의 경로 매칭 방식을 수정합니다. 또한, 예외 타입의 HTTP 상태 코드가 일부 변경되고, properties 파일의 서브프로젝트 커밋 참조가 업데이트되었습니다. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Server
participant GlobalExceptionHandler
Client->>Server: HTTP 요청 (헤더/쿠키 누락)
Server->>GlobalExceptionHandler: MissingRequestHeaderException 또는 MissingRequestCookieException 발생
GlobalExceptionHandler-->>Client: 400 BAD_REQUEST 및 커스텀 메시지 반환
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–20 minutes Possibly related PRs
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/main/java/kr/ac/kumoh/d138/JobForeigner/global/exception/GlobalExceptionHandler.java (2)
78-83: 누락된 헤더에 대한 구체적인 정보 제공을 고려해보세요.새로운
MissingRequestHeaderException핸들러가 추가되어 토큰 리프레시 API의 요구사항을 충족합니다. 다만 어떤 헤더가 누락되었는지에 대한 구체적인 정보를 포함하면 더 유용할 것입니다.다음과 같이 구체적인 헤더명을 포함하는 것을 고려해보세요:
@ExceptionHandler(MissingRequestHeaderException.class) public ResponseEntity<ResponseBody<Void>> handleMissingRequestHeaderException(MissingRequestHeaderException e) { + String customMessage = "필수 HTTP 헤더가 존재하지 않습니다: " + e.getHeaderName(); return ResponseEntity .status(ExceptionType.ESSENTIAL_FIELD_MISSING_ERROR.getStatus()) - .body(ResponseUtil.createFailureResponse(ExceptionType.ESSENTIAL_FIELD_MISSING_ERROR, "필수 HTTP 헤더가 존재하지 않습니다.")); + .body(ResponseUtil.createFailureResponse(ExceptionType.ESSENTIAL_FIELD_MISSING_ERROR, customMessage)); }
85-90: 누락된 쿠키에 대한 구체적인 정보 제공을 고려해보세요.새로운
MissingRequestCookieException핸들러가 추가되어 토큰 리프레시 API의 요구사항을 충족합니다. 마찬가지로 어떤 쿠키가 누락되었는지에 대한 구체적인 정보를 포함하면 더 유용할 것입니다.다음과 같이 구체적인 쿠키명을 포함하는 것을 고려해보세요:
@ExceptionHandler(MissingRequestCookieException.class) public ResponseEntity<ResponseBody<Void>> handleMissingRequestCookieException(MissingRequestCookieException e) { + String customMessage = "필수 쿠키가 존재하지 않습니다: " + e.getCookieName(); return ResponseEntity .status(ExceptionType.ESSENTIAL_FIELD_MISSING_ERROR.getStatus()) - .body(ResponseUtil.createFailureResponse(ExceptionType.ESSENTIAL_FIELD_MISSING_ERROR, "필수 쿠키가 존재하지 않습니다.")); + .body(ResponseUtil.createFailureResponse(ExceptionType.ESSENTIAL_FIELD_MISSING_ERROR, customMessage)); }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/main/java/kr/ac/kumoh/d138/JobForeigner/global/config/security/SecurityConfig.java(0 hunks)src/main/java/kr/ac/kumoh/d138/JobForeigner/global/exception/ExceptionType.java(1 hunks)src/main/java/kr/ac/kumoh/d138/JobForeigner/global/exception/GlobalExceptionHandler.java(4 hunks)src/main/java/kr/ac/kumoh/d138/JobForeigner/global/jwt/filter/JwtAuthenticationFilter.java(1 hunks)src/main/resources/properties(1 hunks)
💤 Files with no reviewable changes (1)
- src/main/java/kr/ac/kumoh/d138/JobForeigner/global/config/security/SecurityConfig.java
🧰 Additional context used
📓 Path-based instructions (1)
**/*.java
⚙️ CodeRabbit Configuration File
**/*.java: This project follows key rules from the NAVER Campus Hackday Java Coding Conventions (partial summary below; see full spec for details). * Indentation: use spaces (no tabs), tab width = 4 spaces. Files must end with Unix LF newline. * Line length: maximum 120 characters. * Imports: single-class imports only, allow wildcard for static imports, group imports with blank lines between sections. * Assignment operators (=,+=,-=, etc.): always have one space before and after; when breaking lines, the operator must start the next line (Binary expressions: operation sign on next line). * Lambda expressions: omit parentheses for a single parameter; surround->with spaces (param -> expression); use braces and explicitreturnfor multi-statement bodies; choose short, clear parameter names to keep intent visible. For the complete set of conventions and detailed examples, please refer to the full spec athttps://naver.github.io/hackday-conventions-java/.
Files:
src/main/java/kr/ac/kumoh/d138/JobForeigner/global/jwt/filter/JwtAuthenticationFilter.javasrc/main/java/kr/ac/kumoh/d138/JobForeigner/global/exception/ExceptionType.javasrc/main/java/kr/ac/kumoh/d138/JobForeigner/global/exception/GlobalExceptionHandler.java
🧠 Learnings (2)
📓 Common learnings
Learnt from: patulus
PR: th-D138/Backend-JobForeigner#59
File: src/main/java/kr/ac/kumoh/d138/JobForeigner/global/jwt/authentication/JwtAuthentication.java:24-24
Timestamp: 2025-07-10T01:43:40.239Z
Learning: Spring Security의 hasRole() 및 hasAnyRole() 메서드는 자동으로 "ROLE_" 접두사를 추가하므로, SecurityConfig에서 MemberType.ADMIN.name()을 사용하고 JwtAuthentication에서 memberType.getKey()를 사용하는 것이 호환됨. SecurityConfig 수정이 불필요함.
src/main/java/kr/ac/kumoh/d138/JobForeigner/global/jwt/filter/JwtAuthenticationFilter.java (1)
Learnt from: patulus
PR: #59
File: src/main/java/kr/ac/kumoh/d138/JobForeigner/global/jwt/authentication/JwtAuthentication.java:24-24
Timestamp: 2025-07-10T01:43:40.239Z
Learning: Spring Security의 hasRole() 및 hasAnyRole() 메서드는 자동으로 "ROLE_" 접두사를 추가하므로, SecurityConfig에서 MemberType.ADMIN.name()을 사용하고 JwtAuthentication에서 memberType.getKey()를 사용하는 것이 호환됨. SecurityConfig 수정이 불필요함.
🧬 Code Graph Analysis (1)
src/main/java/kr/ac/kumoh/d138/JobForeigner/global/exception/GlobalExceptionHandler.java (2)
src/main/java/kr/ac/kumoh/d138/JobForeigner/global/response/ResponseUtil.java (1)
ResponseUtil(5-28)src/main/java/kr/ac/kumoh/d138/JobForeigner/global/exception/ExceptionHandlerFilter.java (2)
ExceptionHandlerFilter(15-32)doFilterInternal(21-31)
🔇 Additional comments (4)
src/main/resources/properties (1)
1-1: 서브모듈 커밋 갱신 후 CI/CD 정상 동작 확인 요청
Subproject commit해시가 변경되었습니다. 서브모듈을 사용하는 빌드·배포 파이프라인에서git submodule update --init --recursive단계가 누락되면 컴파일 오류가 발생할 수 있으니, CI 로그를 한 번 더 점검해 주세요.src/main/java/kr/ac/kumoh/d138/JobForeigner/global/jwt/filter/JwtAuthenticationFilter.java (1)
33-33: 경로 매칭 수정이 적절합니다.JWT 필터에서 제외해야 할 경로들에 슬래시(
/) 접두사를 추가한 것은 올바른 수정입니다. HTTP 요청 URI는 일반적으로 슬래시로 시작하므로, 이 변경으로 토큰 리프레시 API(/api/v1/members/refresh)가 의도한 대로 JWT 필터를 우회할 수 있게 됩니다.src/main/java/kr/ac/kumoh/d138/JobForeigner/global/exception/ExceptionType.java (1)
15-15: HTTP 상태 코드 수정이 적절합니다.
ESSENTIAL_FIELD_MISSING_ERROR의 HTTP 상태 코드를NO_CONTENT(204)에서BAD_REQUEST(400)로 변경한 것은 올바른 수정입니다. 필수 필드 누락은 클라이언트 오류에 해당하므로 400 상태 코드가 의미상 더 적절합니다.src/main/java/kr/ac/kumoh/d138/JobForeigner/global/exception/GlobalExceptionHandler.java (1)
43-43: 로깅 형식 변경이 일관성 있게 적용되었습니다.예외 로깅 형식을 메시지만 기록하도록 변경한 것은 로그 가독성을 향상시킵니다. 특히 일반적인 예외 핸들러에서 전체 스택 트레이스를 기록하도록 한 것은 디버깅에 도움이 됩니다.
Also applies to: 65-65, 94-94
kon28289
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.
수고하셨습니다
What is this PR?🔍
Changes💻
Summary by CodeRabbit
버그 수정
신규 기능
기타