Skip to content

[REFACTOR/#101] 리프레시 토큰 및 state 인증 시 쿠키 기반으로 롤백#102

Merged
JeongGyul merged 1 commit intomainfrom
refactor/#101-revert-cookie-auth
Feb 11, 2026
Merged

[REFACTOR/#101] 리프레시 토큰 및 state 인증 시 쿠키 기반으로 롤백#102
JeongGyul merged 1 commit intomainfrom
refactor/#101-revert-cookie-auth

Conversation

@JeongGyul
Copy link
Collaborator

🔗 Related Issue

📝 Summary

이전에 작업했던 쿠키 기반 인증 방식을 되돌리고, CORS 설정에 프론트엔드 배포 주소를 추가하였습니다.

  • 쿠키 기반 인증 방식
    • 로그인 시 리프레시 토큰은 JSON Body가 아닌 쿠키로 생성하도록 변경
    • 카카오 콜백 API 호출 시 state 값은 쿼리 파라미터가 아닌 쿠키에서 받아오도록 변경
    • 토큰 재발급 시 리프레시 토큰은 쿼리 파라미터가 아닌 쿠키에서 받아오도록 변경
  • CORS 설정
    • 기존에는 와일드카드(*)로 모든 도메인을 허용했었으나, 프론트엔드 배포 주소(https://valuedi-web.vercel.app/)와 로컬 개발환경(http://localhost:5173)만 허용하도록 수정

🔄 Changes

  • API 변경 (추가/수정)
  • 데이터 및 도메인 변경 (DB, 비즈니스 로직)
  • 설정 또는 인프라 관련 변경
  • 리팩토링

💬 Questions & Review Points

📸 API Test Results (Swagger)

✅ Checklist

  • API 테스트 완료
  • 테스트 결과 사진 첨부
  • 빌드 성공 확인 (./gradlew build)

@JeongGyul JeongGyul self-assigned this Feb 11, 2026
@JeongGyul JeongGyul added ♻️ refactor 코드 구조 개선 정규 정규 labels Feb 11, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @JeongGyul, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 인증 시스템의 핵심 변경 사항을 도입하여 리프레시 토큰과 OAuth state 값 관리를 쿠키 기반으로 전환하고, 보안 강화를 위해 CORS 정책을 구체화했습니다. 이러한 변경은 토큰의 안전한 전송과 교차 출처 요청에 대한 통제를 개선하여 애플리케이션의 전반적인 보안 자세를 향상시키는 것을 목표로 합니다.

Highlights

  • 쿠키 기반 인증 롤백: 리프레시 토큰 및 OAuth state 값 처리를 JSON Body 방식에서 쿠키 기반 방식으로 롤백했습니다.
  • CORS 설정 강화: CORS 설정을 와일드카드('*')에서 특정 프론트엔드 배포 주소 및 로컬 개발 환경으로 제한했습니다.
  • 인증 API 변경: 로그인, 토큰 재발급, 로그아웃 API에서 리프레시 토큰을 쿠키로 관리하도록 변경했습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/main/java/org/umc/valuedi/domain/auth/controller/AuthController.java
    • HttpServletResponse 및 JwtUtil을 임포트했습니다.
    • kakaoLogin 메서드에서 OAuth state 값을 쿠키에 저장하고, 로그인 URL만 반환하도록 수정했습니다.
    • kakaoCallback 메서드에서 OAuth state 값을 쿠키에서 읽어오고, 로그인 성공 시 리프레시 토큰을 쿠키에 추가하도록 변경했습니다.
    • localLogin 메서드에서 로그인 성공 시 리프레시 토큰을 쿠키에 추가하도록 변경했습니다.
    • tokenReissue 메서드에서 리프레시 토큰을 @CookieValue로 받아오고, 재발급된 리프레시 토큰을 쿠키에 다시 저장하도록 수정했습니다.
    • logout 메서드에서 리프레시 토큰 쿠키를 삭제하도록 추가했습니다.
  • src/main/java/org/umc/valuedi/domain/auth/controller/AuthControllerDocs.java
    • kakaoLogin의 반환 타입과 설명을 업데이트하여 state 값이 쿠키에 저장됨을 명시했습니다.
    • kakaoCallback, localLogin, tokenReissue의 Swagger 설명을 업데이트하여 리프레시 토큰이 쿠키에 저장됨을 명시하고, 응답 DTO에서 리프레시 토큰 필드를 제거했습니다.
    • 각 메서드의 파라미터에 HttpServletResponse 및 @CookieValue 관련 변경 사항을 반영했습니다.
  • src/main/java/org/umc/valuedi/domain/auth/converter/AuthConverter.java
    • toLoginUrlDTO 메서드를 제거했습니다.
  • src/main/java/org/umc/valuedi/domain/auth/dto/res/AuthResDTO.java
    • LoginResultDTO에서 refreshToken 필드에 @JsonIgnore 어노테이션을 추가하여 JSON 응답에서 제외했습니다.
    • LoginUrlDTO 레코드를 제거했습니다.
  • src/main/java/org/umc/valuedi/global/config/SecurityConfig.java
  • src/main/java/org/umc/valuedi/global/security/util/CookieUtil.java
    • addCookie 메서드에서 secure 속성을 true로, sameSite 속성을 None으로 변경했습니다.
Activity
  • 이 PR에 대한 추가적인 활동(댓글, 검토 진행 상황 등)은 아직 없습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

전반적으로 리프레시 토큰과 OAuth state 관리를 쿠키 기반으로 변경한 리팩토링이 잘 적용되었습니다. 특히 CORS 설정을 구체적인 도메인으로 제한하고, 쿠키에 securehttpOnly 속성을 적용하여 보안을 강화한 점이 좋습니다.
AuthController에서 쿠키를 설정하는 로직이 여러 곳에 중복되어 있어, 이를 별도의 메소드로 추출하고 관련 문자열들을 상수로 관리하도록 제안하는 리뷰 의견을 남겼습니다. 이를 통해 코드의 유지보수성과 가독성을 더욱 향상시킬 수 있을 것입니다.

@JeongGyul JeongGyul merged commit 7754e2a into main Feb 11, 2026
1 check passed
@JeongGyul JeongGyul deleted the refactor/#101-revert-cookie-auth branch February 11, 2026 11:28
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.

[REFACTOR] 리프레시 토큰 및 state 인증 시 쿠키 기반으로 롤백

1 participant