Skip to content

Conversation

@sudhdkso
Copy link
Contributor

@sudhdkso sudhdkso commented Aug 6, 2025

#️⃣연관된 이슈

ex) #이슈번호, #이슈번호

🔀반영 브랜치

feat/redirect-to-client -> develop

🔧변경 사항

  • 카카오 소셜로그인시 클라이언트로 리다이렉트하도록 수정하였습니다.

💬리뷰 요구사항(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요
ex) 메서드 XXX의 이름을 더 잘 짓고 싶은데 혹시 좋은 명칭이 있을까요

Summary by CodeRabbit

  • 버그 수정
    • 카카오 로그인 콜백 시 리다이렉트 방식이 개선되어, 로그인 후 더 원활하게 메인 페이지로 이동됩니다.
    • 카카오 연동 오류 발생 시 에러 메시지 기록이 강화되어, 문제 발생 시 더 정확한 원인 파악이 가능합니다.
    • 카카오 로그인 콜백 테스트가 리다이렉트 응답을 올바르게 검증하도록 업데이트되었습니다.

@coderabbitai
Copy link

coderabbitai bot commented Aug 6, 2025

Walkthrough

AuthControllerkakaoLoginCallback 메서드는 HttpServletResponse를 파라미터로 받아 직접 쿠키 설정과 리다이렉트를 수행하도록 변경되었으며, 반환 타입과 예외 선언이 수정되었습니다. KakaoClientjoin 메서드에서는 예외 로그에 예외 메시지가 추가되었습니다. AuthControllerTestkakaoLoginCallback 테스트는 HTTP 3xx 리다이렉션 상태를 기대하도록 변경되었습니다.

Changes

Cohort / File(s) Change Summary
AuthController 리팩토링
src/main/java/com/dnd/moddo/domain/auth/controller/AuthController.java
kakaoLoginCallback 메서드가 HttpServletResponse를 추가 파라미터로 받고 IOException을 던지도록 변경. 응답 헤더에 쿠키를 직접 추가하고 sendRedirect를 호출하도록 수정. 반환 타입 및 메서드 시그니처 변경.
KakaoClient 예외 로그 개선
src/main/java/com/dnd/moddo/domain/auth/service/KakaoClient.java
join 메서드의 RestClientResponseException 캐치 블록에서 로그 태그를 수정하고, 예외 메시지(e.getMessage())를 로그에 추가. 기존 예외 처리 흐름은 유지.
AuthController 테스트 수정
src/test/java/com/dnd/moddo/domain/auth/controller/AuthControllerTest.java
kakaoLoginCallback 테스트가 HTTP 200 OK 대신 3xx 리다이렉션 상태를 기대하도록 변경. 테스트 요청 및 문서화는 유지.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant AuthController
    participant HttpServletResponse

    Client->>AuthController: kakaoLoginCallback(code)
    AuthController->>HttpServletResponse: add Set-Cookie header
    AuthController->>HttpServletResponse: sendRedirect("https://www.moddo.kr")
    HttpServletResponse-->>Client: HTTP 302 Redirect with Set-Cookie
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Poem

🥕
쿠키를 굽고 리다이렉트해,
로그인 흐름이 새로워졌네!
예외 메시지도 꼼꼼히 챙겨,
로그 속 진실을 더 깊이 담아.
테스트도 리다이렉션을 맞이해,
토끼는 깡총, 코드도 깔끔!

( ˘▽˘)っ♬

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4982b62 and e7868df.

📒 Files selected for processing (2)
  • src/main/java/com/dnd/moddo/domain/auth/controller/AuthController.java (3 hunks)
  • src/main/java/com/dnd/moddo/domain/auth/service/KakaoClient.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/java/com/dnd/moddo/domain/auth/service/KakaoClient.java
  • src/main/java/com/dnd/moddo/domain/auth/controller/AuthController.java

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.
  • 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for 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.

@sudhdkso sudhdkso requested a review from choyeseol August 6, 2025 05:55
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 0b4e7fc and f412174.

📒 Files selected for processing (2)
  • src/main/java/com/dnd/moddo/domain/auth/controller/AuthController.java (3 hunks)
  • src/main/java/com/dnd/moddo/domain/auth/service/KakaoClient.java (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/main/java/com/dnd/moddo/domain/auth/service/KakaoClient.java (1)
src/main/java/com/dnd/moddo/global/exception/GlobalExceptionHandler.java (1)
  • GlobalExceptionHandler (9-43)
🔇 Additional comments (1)
src/main/java/com/dnd/moddo/domain/auth/controller/AuthController.java (1)

3-3: 필요한 import가 적절히 추가되었습니다.

IOExceptionHttpServletResponse는 변경된 메서드 구현에 필요한 의존성들입니다.

Also applies to: 25-25

Comment on lines +64 to +65
response.addHeader("Set-Cookie", cookie);
response.sendRedirect("https://www.moddo.kr");
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

하드코딩된 URL을 설정값으로 분리하고 보안을 고려해주세요.

현재 구현에서 몇 가지 개선점이 있습니다:

  1. 하드코딩된 URL: "https://www.moddo.kr"이 하드코딩되어 있어 환경별 설정이 어렵습니다.
  2. 보안 고려사항: 외부 도메인으로의 리다이렉트 시 검증이 필요할 수 있습니다.

다음과 같이 개선을 제안합니다:

+@Value("${app.client.redirect-url:https://www.moddo.kr}")
+private String clientRedirectUrl;

 public void kakaoLoginCallback(@RequestParam @NotBlank String code,
     HttpServletResponse response) throws IOException {
     
     TokenResponse tokenResponse = authService.loginOrRegisterWithKakao(code);
     
     String cookie = createCookie("accessToken", tokenResponse.accessToken()).toString();
     response.addHeader("Set-Cookie", cookie);
-    response.sendRedirect("https://www.moddo.kr");
+    response.sendRedirect(clientRedirectUrl);
 }
📝 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
response.addHeader("Set-Cookie", cookie);
response.sendRedirect("https://www.moddo.kr");
// Add this at the top of your controller class (and import org.springframework.beans.factory.annotation.Value)
@Value("${app.client.redirect-url:https://www.moddo.kr}")
private String clientRedirectUrl;
public void kakaoLoginCallback(@RequestParam @NotBlank String code,
HttpServletResponse response) throws IOException {
TokenResponse tokenResponse = authService.loginOrRegisterWithKakao(code);
String cookie = createCookie("accessToken", tokenResponse.accessToken()).toString();
response.addHeader("Set-Cookie", cookie);
response.sendRedirect(clientRedirectUrl);
}
🤖 Prompt for AI Agents
In src/main/java/com/dnd/moddo/domain/auth/controller/AuthController.java at
lines 64-65, the redirect URL "https://www.moddo.kr" is hardcoded, which reduces
flexibility and may pose security risks. To fix this, externalize the URL into a
configuration property (e.g., application.properties or environment variable)
and inject it into the controller. Additionally, implement validation to ensure
the redirect URL is safe and allowed before calling response.sendRedirect,
preventing open redirect vulnerabilities.

@github-actions
Copy link

github-actions bot commented Aug 6, 2025

📝 테스트 커버리지 리포트입니다!

File Coverage [89.22%] 🍏
KakaoClient.java 89.22% 🍏
Total Project Coverage 92.84% 🍏

@github-actions
Copy link

github-actions bot commented Aug 6, 2025

📝 테스트 커버리지 리포트입니다!

File Coverage [89.22%] 🍏
KakaoClient.java 89.22% 🍏
Total Project Coverage 92.84% 🍏

@sudhdkso sudhdkso merged commit 488f455 into develop Aug 7, 2025
3 checks passed
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.

3 participants