Skip to content

Conversation

@Yujin1219
Copy link
Member

@Yujin1219 Yujin1219 commented Dec 9, 2025

#️⃣ 연관된 이슈

📝 작업 내용

  • AuthUtil 유틸리티 클래스 생성
    • HTTP 요청에서 JWT 토큰 추출 및 검증
    • 토큰에서 사용자 ID 추출 기능
  • Controller 인증 적용
    • 모든 임시 하드코딩(1L) 제거
    • GET /api/user/me: 마이페이지 조회 (경로 변경)

📌 공유 사항

✅ 체크리스트

  • Reviewer에 팀원들을 선택 했나요?
  • Assignees에 본인을 선택 했나요?
  • Merge 하려는 브랜치가 올바르게 설정되어 있나요?
  • 컨벤션을 지키고 있나요?
  • 로컬에서 실행했을 때 에러가 발생하지 않나요?
  • 불필요한 주석이 제거되었나요?
  • 코드 스타일이 일관적인가요?

스크린샷 (선택)

💬 리뷰 요구사항 (선택)

ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요? or 변경 사항 등

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • JWT 기반 인증을 통한 사용자 식별 체계 도입으로 보안 강화
  • 변경 사항

    • 사용자 정보 조회 엔드포인트 변경: 사용자 ID를 경로 매개변수 대신 인증 토큰으로 확인
    • 여행 계획 및 사용자 정보 조회 시 현재 인증된 사용자 기반 처리

✏️ Tip: You can customize this high-level summary in your review settings.

@Yujin1219 Yujin1219 self-assigned this Dec 9, 2025
@Yujin1219 Yujin1219 added the ♻️ refactor 코드 리팩토링 label Dec 9, 2025
@Yujin1219 Yujin1219 merged commit 9e31d17 into develop Dec 9, 2025
2 checks passed
@Yujin1219 Yujin1219 deleted the feat/#15 branch December 9, 2025 17:50
@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Walkthrough

AuthUtil 유틸리티 클래스를 신규 추가하고, TripPlanController와 UserController에서 하드코딩된 userId를 HttpServletRequest에서 동적으로 추출하도록 변경했습니다. 각 컨트롤러는 AuthUtil을 주입받아 인증된 사용자의 ID를 획득합니다.

Changes

Cohort / File(s) Change Summary
Authentication Utility
src/main/java/com/example/triptalk/global/security/AuthUtil.java
신규 Spring 컴포넌트로 JWT 토큰을 Authorization 헤더에서 추출, 검증하고 토큰으로부터 사용자 이메일을 파싱하여 UserRepository를 통해 사용자 ID 반환
TripPlan Controller
src/main/java/com/example/triptalk/domain/tripPlan/controller/TripPlanController.java
AuthUtil 의존성 주입 추가, getTripPlan, getMyTripPlans, markTripPlanAsTraveled 메서드 서명에 HttpServletRequest 매개변수 추가, 하드코딩된 userId(1L) 제거 후 요청에서 동적으로 userId 획득
User Controller
src/main/java/com/example/triptalk/domain/user/controller/UserController.java
AuthUtil 의존성 주입 추가, 엔드포인트 경로 GET /{userId}에서 GET /me로 변경, getUserInfo 메서드 서명을 Long userId 매개변수에서 HttpServletRequest 매개변수로 변경

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목은 JWT 기반 인증을 API에 적용하는 것으로, 변경사항의 핵심 내용(AuthUtil 생성 및 Controller 리팩토링)을 명확하게 반영하고 있습니다.
Description check ✅ Passed PR 설명이 템플릿 구조를 따르고 있으며, 연관된 이슈, 작업 내용, 체크리스트를 포함하고 있습니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#15

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a 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/com/example/triptalk/global/security/AuthUtil.java (1)

25-35: 토큰/유저 예외 구분 및 매 요청 DB 조회 전략 한 번만 정리해 두는 것을 제안합니다

현재는 토큰 검증 실패 시 _UNAUTHORIZED, 유저 미존재 시 USER_NOT_FOUND로 분기하고, 이메일 기준으로 매 요청마다 DB 조회를 수행하고 있습니다.

  • 보안·도메인 요구사항상 “잘못된 토큰”과 “존재하지 않는/탈퇴한 유저”를 클라이언트에서 구분해도 되는지(또는 하나의 401 응답으로 통합할지) 한 번만 팀 내에서 정리해 두시면 좋겠습니다.
  • 트래픽이 커질 경우를 대비해, 토큰에 userId를 직접 포함하거나(신뢰 가능한 서명 전제), 필터/인터셉터에서 한 번만 조회해 컨텍스트/리퀘스트 어트리뷰트에 올리는 구조로 리팩터링하는 것도 장기적으로 고려할 만합니다.
src/main/java/com/example/triptalk/domain/tripPlan/controller/TripPlanController.java (1)

7-58: 하드코딩된 userId 제거 및 AuthUtil 연동이 적절합니다

세 엔드포인트 모두 JWT 기반 userId를 사용하도록 정리된 방향이 요구사항과 잘 맞습니다. 다만 HttpServletRequest + authUtil.getUserIdFromRequest(request) 패턴이 컨트롤러 전반에 반복될 가능성이 크니, 추후에는 필터/인터셉터나 커스텀 ArgumentResolver·컨텍스트를 통해 인증 사용자 정보를 주입하는 구조로 공통화하는 것도 고려해 보시면 좋겠습니다.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 592a405 and c5c5130.

📒 Files selected for processing (3)
  • src/main/java/com/example/triptalk/domain/tripPlan/controller/TripPlanController.java (3 hunks)
  • src/main/java/com/example/triptalk/domain/user/controller/UserController.java (2 hunks)
  • src/main/java/com/example/triptalk/global/security/AuthUtil.java (1 hunks)
🔇 Additional comments (2)
src/main/java/com/example/triptalk/global/security/AuthUtil.java (1)

13-49: JWT 기반 사용자 ID 추출 유틸 구현이 명확합니다

토큰 파싱 → 검증 → 이메일 기반 사용자 조회까지 흐름이 단순하고, 토큰 형식 검사도 resolveToken으로 잘 분리되어 있어서 재사용하기 좋습니다.

src/main/java/com/example/triptalk/domain/user/controller/UserController.java (1)

6-27: /user/me 엔드포인트로의 전환과 AuthUtil 연동이 자연스럽습니다

경로를 /api/user/{userId}에서 /api/user/me로 바꾸고, JWT에서 userId를 추출해 서비스에 전달하는 구조가 “현재 로그인 유저 마이페이지”라는 도메인에 더 잘 맞습니다. 이 변경이 사용 중인 클라이언트(웹/앱)와 API 문서에 모두 반영되었는지만 한 번만 같이 확인해 주세요.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

♻️ refactor 코드 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants