Skip to content

Conversation

@minjee2758
Copy link
Collaborator

@minjee2758 minjee2758 commented Jun 14, 2025

작업 내용

WhiteList 목록에 /api 경로 추가

-> 기존 PR에 반영되지 않아 로그인 이슈가 있었습니다!


해결해야 할 문제

  • Exception을 세분화해야합니다,, 지금은 에러 처리가 잘 되지 않고 있습니다

참고 사항

image
  • 오늘 가족모임이 있어서 댓글 달아주시면 밤에 다시 확인하겠습니다!

코드 리뷰 전 확인 체크리스트

  • 불필요한 콘솔 로그, 주석 제거
  • 커밋 메시지 컨벤션 준수 (type : )
  • 기능 정상 동작 확인

Summary by CodeRabbit

Summary by CodeRabbit

  • 신규 기능

    • Google 소셜 로그인 버튼이 OAuth2 인증 플로우를 직접 시작하도록 변경되었습니다.
  • 버그 수정

    • 로그인 페이지의 Google 로그인 링크가 올바른 OAuth2 인증 URL로 수정되었습니다.
  • 스타일

    • 로그 메시지가 더 상세한 정보를 포함하도록 개선되었습니다.
  • 리팩터

    • 인증 및 보안 관련 엔드포인트의 경로가 /api/auth/**로 통합 및 정비되었습니다.
    • JWT 토큰 검증 예외 처리 로직이 강화되어 JWT 관련 오류 시 적절한 응답이 반환됩니다.

@minjee2758 minjee2758 self-assigned this Jun 14, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 14, 2025

"""

Walkthrough

인증 및 보안 관련 엔드포인트의 URL 경로가 /api/auth/**로 통합 및 변경되었으며, JWT 필터의 화이트리스트 경로도 이에 맞게 수정되었습니다. 로그인 뷰 및 Google 소셜 로그인 버튼이 OAuth2 인증 플로우를 직접 시작하도록 링크가 변경되었습니다. 또한, AuthService의 리프레시 토큰 관련 로그가 상세하게 개선되었고, ExceptionHandlingFilter는 JWT 예외 처리 범위를 확장하고 예외 전파 방식을 조정했습니다.

Changes

파일/경로 요약 변경 내용 요약
src/main/java/org/ezcode/codetest/application/usermanagement/auth/service/AuthService.java refreshToken 메서드 내 로그 메시지에 사용자 ID 및 토큰 값을 포함하도록 상세화
src/main/java/org/ezcode/codetest/common/security/config/SecurityConfig.java
src/main/java/org/ezcode/codetest/common/security/util/JwtFilter.java
인증 관련 엔드포인트 경로를 /auth/**, /signup에서 /api/auth/**로 통합 및 변경
src/main/java/org/ezcode/codetest/presentation/usermanagement/view/AuthViewController.java oAuthLogin() 메서드의 반환값을 상대 경로에서 Google OAuth2 인증 URL로 변경
src/main/resources/templates/login-page.html Google 소셜 로그인 버튼의 링크를 /login에서 /oauth2/authorization/google로 변경
src/main/java/org/ezcode/codetest/common/security/util/ExceptionHandlingFilter.java JWT 예외 처리 범위 확장(JwtException 추가), IOException 및 ServletException은 재던짐, 일반 예외는 재던짐으로 변경

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Frontend (login-page.html)
    participant AuthViewController
    participant GoogleOAuth2

    User->>Frontend (login-page.html): 방문 및 Google 로그인 버튼 클릭
    Frontend->>AuthViewController: /login 요청
    AuthViewController-->>User: http://localhost:8080/oauth2/authorization/google 반환
    User->>GoogleOAuth2: OAuth2 인증 플로우 시작
Loading

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • pokerbearkr
  • NCookies
  • Kimminu7

Poem

🥕
로그인 길이 바뀌었네,
구글 버튼 누르면 곧장 가네!
토큰 로그도 더 또렷하게,
토끼는 깡총, 보안은 튼튼하게.
변화 속에서도,
인증의 길은 한층 더 명확하게!
🐇
"""

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ecbbd60 and 3b02971.

📒 Files selected for processing (5)
  • src/main/java/org/ezcode/codetest/application/usermanagement/auth/service/AuthService.java (1 hunks)
  • src/main/java/org/ezcode/codetest/common/security/config/SecurityConfig.java (1 hunks)
  • src/main/java/org/ezcode/codetest/common/security/util/JwtFilter.java (1 hunks)
  • src/main/java/org/ezcode/codetest/presentation/usermanagement/view/AuthViewController.java (1 hunks)
  • src/main/resources/templates/login-page.html (1 hunks)
🔇 Additional comments (2)
src/main/resources/templates/login-page.html (1)

35-37: Google 로그인 URL 수정 적용 확인됨
백엔드의 OAuth2 엔드포인트(/oauth2/authorization/google)와 일치하도록 href가 수정됐습니다. 문제 없습니다.

src/main/java/org/ezcode/codetest/common/security/util/JwtFilter.java (1)

37-40: 로그아웃·비밀번호 재설정 등 추가 엔드포인트 확인 필요
화이트리스트가 /api/auth/signin|signup|refresh 세 가지만 허용하고 있습니다. 로그아웃(/api/auth/logout)이나 비밀번호 재설정 등의 신규 엔드포인트를 도입할 경우 필터를 통과하지 못해 401이 반환될 수 있으니, API 스펙을 다시 점검해 추가 여부를 검토해 주세요.

Comment on lines +64 to 65
"/api/auth/**",
"/login",
Copy link

@coderabbitai coderabbitai bot Jun 14, 2025

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

화이트리스트 경로 하드코딩 분산 ⇒ 중앙집중화 필요
/api/auth/** 경로를 SecurityConfig와 JwtFilter 두 곳에서 각각 문자열로 관리하고 있습니다. 경로 변경 시 두 파일이 불일치할 위험이 있으니 상수를 별도 클래스로 분리하거나 application.yml에 프로퍼티로 두고 주입하는 방식으로 중복을 제거하세요.

🤖 Prompt for AI Agents
In src/main/java/org/ezcode/codetest/common/security/config/SecurityConfig.java
around lines 64 to 65, the whitelist path "/api/auth/**" is hardcoded both here
and in JwtFilter, causing duplication and risk of inconsistency. To fix this,
extract the path string into a shared constant in a separate class or define it
as a property in application.yml and inject it into both SecurityConfig and
JwtFilter, ensuring centralized management of the whitelist path.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

웅 나중에 클래스로 분리할게

Copy link

Choose a reason for hiding this comment

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

@minjee2758 네, 이해했습니다! 현재 PR에 집중하시고 리팩토링은 나중에 진행하시면 됩니다.

혹시 이 개선사항을 추적하기 위해 별도 이슈를 생성해 드릴까요? 나중에 놓치지 않고 처리하실 수 있도록 도움이 될 것 같습니다.

ᕦ(๑^╹^๑)ᕤ

Comment on lines +145 to 148
log.info("유저 아이디 가져옴 id : {}", userId);
String savedToken = redisTemplate.opsForValue().get("RefreshToken:" + userId);
log.info("저장된 토큰 가져옴");
log.info("저장된 토큰 가져옴 {}", savedToken);
if (savedToken==null || !savedToken.equals(token)){
Copy link

@coderabbitai coderabbitai bot Jun 14, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

민감 정보(리프레시 토큰) 로그 출력은 보안 위험
log.info("저장된 토큰 가져옴 {}", savedToken); 로 리프레시 토큰 전체를 남기면 토큰 탈취 위험이 있습니다. 토큰 앞·뒤 몇 글자만 마스킹하거나 로그 레벨을 DEBUG 이하로 낮추고 운영 환경에서는 끄는 것이 안전합니다.

-log.info("저장된 토큰 가져옴 {}", savedToken);
+log.debug("저장된 토큰 조회 완료. length={}", savedToken != null ? savedToken.length() : 0);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
log.info("유저 아이디 가져옴 id : {}", userId);
String savedToken = redisTemplate.opsForValue().get("RefreshToken:" + userId);
log.info("저장된 토큰 가져옴");
log.info("저장된 토큰 가져옴 {}", savedToken);
if (savedToken==null || !savedToken.equals(token)){
log.info("유저 아이디 가져옴 id : {}", userId);
String savedToken = redisTemplate.opsForValue().get("RefreshToken:" + userId);
log.debug("저장된 토큰 조회 완료. length={}", savedToken != null ? savedToken.length() : 0);
if (savedToken == null || !savedToken.equals(token)) {
🤖 Prompt for AI Agents
In
src/main/java/org/ezcode/codetest/application/usermanagement/auth/service/AuthService.java
around lines 145 to 148, the code logs the full refresh token which poses a
security risk. Modify the logging to mask the token by showing only the first
and last few characters with the middle part replaced by asterisks or similar,
or change the log level to DEBUG and ensure it is disabled in production
environments to prevent token exposure.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

개발할떄 필요해서 해놨어 토끼얌

Copy link

Choose a reason for hiding this comment

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

@minjee2758 개발 중에 디버깅할 때 필요하다는 점 이해해요! 👍

다만 운영 환경으로 배포될 때를 고려해서, 환경별로 로그 레벨을 다르게 설정하는 것도 좋은 방법이에요:

if (log.isDebugEnabled()) {
    log.debug("저장된 토큰 가져옴 {}", savedToken);
} else {
    log.info("저장된 토큰 조회 완료");
}

또는 application.yml에서 개발/운영 환경별로 로그 레벨을 다르게 설정하시면 개발할 때는 상세한 로그를, 운영에서는 안전한 로그를 사용할 수 있어요.

하지만 지금 개발 단계에서 필요하시다면 그대로 두셔도 괜찮습니다! 😊

@pokerbearkr
Copy link
Contributor

충돌나영

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 (1)
src/main/java/org/ezcode/codetest/common/security/util/ExceptionHandlingFilter.java (1)

34-36: JwtException 블록 로그 레벨 및 메시지 통일 고려

JwtException은 서명 오류·만료·지원되지 않는 토큰 등 모든 하위 예외의 슈퍼클래스입니다.
이미 세 가지 상세 예외를 앞에서 처리했으므로, 여기서는 미처 분류하지 못한 JWT 예외만 들어옵니다.
로그 레벨이 warn이고, 앞선 블록들은 info라 레벨이 달라 모니터링 시 혼선이 있을 수 있습니다. 전부 warn 또는 info로 통일하는 편이 관리 측면에서 낫습니다.
또한 사용자 메시지도 한글·영문 혼용 대신 일관성을 유지해 주세요.

-log.warn("JWT 관련 예외", e);
+log.info("Unhandled JWT 예외", e);  // 또는 전 블록을 warn 으로 상향
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b02971 and 121433e.

📒 Files selected for processing (3)
  • src/main/java/org/ezcode/codetest/common/security/util/ExceptionHandlingFilter.java (2 hunks)
  • src/main/java/org/ezcode/codetest/common/security/util/JwtFilter.java (1 hunks)
  • src/main/java/org/ezcode/codetest/presentation/usermanagement/view/AuthViewController.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/java/org/ezcode/codetest/common/security/util/JwtFilter.java
  • src/main/java/org/ezcode/codetest/presentation/usermanagement/view/AuthViewController.java
🔇 Additional comments (1)
src/main/java/org/ezcode/codetest/common/security/util/ExceptionHandlingFilter.java (1)

37-41: Generic Exception 재전파 정책 점검 필요

IOException | ServletException뿐 아니라 Exception까지 그대로 throw 하도록 변경했는데,
컨트롤러 레이어에서 해당 예외를 처리하지 않으면 서블릿 컨테이너 전역 오류 페이지로 넘어가며 스택트레이스가 사용자에게 노출될 위험이 있습니다.

  1. 컨트롤러에 @ExceptionHandler가 준비돼 있는지 확인하거나,
  2. 여기서 HttpServletResponse.sendError(500, ...)로 매핑 후 로그만 남기도록 하는 방식을 검토해 주세요.

외부로 노출되지 않는 커스텀 예외로 감싸 재전파하는 것도 고려할 수 있습니다.

@thezz9 thezz9 merged commit a119515 into dev Jun 14, 2025
2 checks passed
@thezz9 thezz9 deleted the refactor/userSecurity branch June 14, 2025 10:56
thezz9 pushed a commit that referenced this pull request Jun 14, 2025
* refactor : api 경로 추가, oauth 경로 수정

* refactor : whitelist 경로 수정

* refactor : redirect url 수정
thezz9 added a commit that referenced this pull request Jun 14, 2025
* build : update build.gradle for Redis

* refactor : Judge0 비동기 병렬 요청 구현

* refactor : 비동기 병렬 요청 구현을 위한 Application, dto

* refactor : 비동기 병렬 요청 구현을 위한 config 파일

* feat : Redis Stream 구현

* refactor : 병렬 요청에서 SSE 구별을 위한 인메모리 저장

* refactor : 테스트용 UI

* refactor : 그룹핑 처리 DTO로 책임 분리

* refactor : Judge0 polling 예외처리 고도화

* refactor : api 경로 수정

* refactor : 서비스 로직 리팩토링

* refactor : 모델 객체 추가

* refactor : 예외 코드 추가

* Refactor : html(google oauth)로 리다이렉팅되는 문제 해결 (#57)

* refactor : logout HttpServeletRequest를 컨트롤러에서 String으로 추출 후 service로 전달

* refactor : whitelist 등록

* refactor : 에러 발생 시, html응답 대신 Json응답으로 받을 수 있도록 리팩토링

* refactor : requestMapping으로 앞에 일괄적으로 /api 달기

* feat : 게임 캐릭터 생성 기능, 아이템 생성 기능, 아이템 뽑기, 스테이터스 확인, 아이템 장착 기능 추가 (#58)

* feat : 게임 도메인 엔티티 생성 및 스킬, 아이템 효과 정의

* feat : 게임 도메인 서비스, 아이템 뽑기 도메인서비스 추가, 랜덤 인카운터 추가

* feat : 아이템 장착, 뽑기, 인벤토리 오픈, 스탯 확인, 캐릭터 생성 기능 추가

# Conflicts:
#	src/main/java/org/ezcode/codetest/common/security/config/SecurityConfig.java

* chore : properties 수정

* chore : properties 수정

* chore : securityconfig 오타수정

* chore : 오타수정

* chore : 오타수정

* chore : 무수히 많은 오타수정, 누락된 어노테이션 추가

* docs : 환경변수 추가

* docs : 오타수정

---------

Co-authored-by: pokerbearkr <[email protected]>

* Refactor : Filter WhiteList 수정 (#59)

* refactor : api 경로 추가, oauth 경로 수정

* refactor : whitelist 경로 수정

* refactor : redirect url 수정

* refactor : Submission Stream

---------

Co-authored-by: MIN <[email protected]>
Co-authored-by: chat26666 <[email protected]>
Co-authored-by: pokerbearkr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants