Skip to content

Sisc1 209 be redirect url 프론트로 전달#106

Merged
Kosw6 merged 6 commits intomainfrom
SISC1-209-BE-redirect-url-프론트로-전달
Nov 14, 2025

Hidden character warning

The head ref may contain hidden characters: "SISC1-209-BE-redirect-url-\ud504\ub860\ud2b8\ub85c-\uc804\ub2ec"
Merged

Sisc1 209 be redirect url 프론트로 전달#106
Kosw6 merged 6 commits intomainfrom
SISC1-209-BE-redirect-url-프론트로-전달

Conversation

@msciki7
Copy link
Contributor

@msciki7 msciki7 commented Nov 14, 2025

Summary by CodeRabbit

릴리스 노트

  • 보안 개선

    • 액세스 및 리프레시 토큰을 위한 별도의 쿠키 구현으로 보안 강화 (HttpOnly, Secure, SameSite=None 설정 포함)
    • 사용자 엔드포인트에 대한 인증 요구사항 적용
  • 최적화

    • 로그 출력 최적화로 시스템 성능 향상

@coderabbitai
Copy link

coderabbitai bot commented Nov 14, 2025

Warning

Rate limit exceeded

@msciki7 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 46 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between eba8b21 and 7c55496.

📒 Files selected for processing (1)
  • backend/src/main/java/org/sejongisc/backend/common/auth/config/OAuth2SuccessHandler.java (1 hunks)

개요

OAuth2 인증 처리 로직이 개선되었습니다. 액세스 및 리프레시 쿠키를 별도로 관리하도록 변경되었으며, 보안 설정이 조정되고, 로깅 성능이 최적화되었습니다.

변경 사항

분류 / 파일 요약
로깅 최적화
backend/src/main/java/org/sejongisc/backend/common/auth/config/CustomOAuth2UserService.java
OAuth2 속성 로그를 디버그 레벨로 제한하는 조건 추가 (log.isDebugEnabled() 가드)
쿠키 관리 및 리다이렉트 개선
backend/src/main/java/org/sejongisc/backend/common/auth/config/OAuth2SuccessHandler.java
단일 쿠키를 두 개의 쿠키로 분리 (액세스: 1시간, 리프레시: 2주); 동적 쿼리 매개변수 제거 및 리다이렉트 URL 단순화
보안 정책 조정
backend/src/main/java/org/sejongisc/backend/common/auth/config/SecurityConfig.java
/api/auth/oauth 공개 노출 제거; /api/user/**에 인증 요구사항 추가

시퀀스 다이어그램

sequenceDiagram
    participant Client
    participant OAuth2SuccessHandler
    participant Browser

    Client->>OAuth2SuccessHandler: OAuth2 인증 성공
    activate OAuth2SuccessHandler
    
    Note over OAuth2SuccessHandler: 액세스 쿠키 생성<br/>(1시간, HttpOnly, Secure)
    OAuth2SuccessHandler->>Browser: Set-Cookie: access=token1
    
    Note over OAuth2SuccessHandler: 리프레시 쿠키 생성<br/>(2주, HttpOnly, Secure)
    OAuth2SuccessHandler->>Browser: Set-Cookie: refresh=token2
    
    Note over OAuth2SuccessHandler: 동적 쿼리 파라미터 제거<br/>(이전: ?accessToken=...&name=...)
    OAuth2SuccessHandler->>Browser: 리다이렉트 (정적 URL)
    
    deactivate OAuth2SuccessHandler
    Browser->>Client: 쿠키 설정 완료 및 리다이렉트
Loading

코드 리뷰 예상 노력

🎯 2 (단순) | ⏱️ ~12분

  • 쿠키 분리 로직 검증 (HttpOnly, Secure, SameSite 설정 확인)
  • 리다이렉트 URL 단순화로 인한 동작 변화 확인
  • 보안 설정의 /api/user/** 인증 요구사항이 의도한 엔드포인트를 올바르게 보호하는지 검증

연관된 가능한 PR

제안된 검토자

  • discipline24

🐰 쿠키 두 개, 한 바구니에 담겨
액세스는 빠르게, 리프레시는 오래
보안의 담장 높아지고
로그는 조용히, 필요할 때만 속삭여
인증의 길, 더욱 견고해진다 🔐

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경사항의 핵심인 리다이렉트 URL 처리 변경을 부분적으로만 반영하며, OAuth2 쿠키 분리 및 보안 설정 변경 등 다른 중요한 변경사항들은 명시하지 않음.

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

🧹 Nitpick comments (1)
backend/src/main/java/org/sejongisc/backend/common/auth/config/OAuth2SuccessHandler.java (1)

92-97: 리다이렉트 동작 변경을 검증하세요.

쿼리 파라미터를 통한 데이터 전달이 제거되었습니다:

  • accessToken, name, userId가 더 이상 URL에 포함되지 않음
  • 프론트엔드가 이제 쿠키에서 이 정보를 읽어야 함
  • 주석 처리된 코드(lines 93-95, 97)는 필요 없다면 삭제하는 것이 좋습니다

프론트엔드가 이 변경사항에 맞게 업데이트되었는지 확인하세요. 특히:

  1. 프론트엔드가 쿠키에서 access 토큰을 읽도록 수정되었는지
  2. 사용자 정보(name, userId)를 별도 API 호출로 가져오는지
  3. /oauth/success 라우트가 쿼리 파라미터 없이 동작하는지

주석 처리된 코드를 제거하여 코드 가독성을 개선하는 것을 고려하세요:

        String redirectUrl = "http://localhost:5173/oauth/success";
-//                + "?accessToken=" + accessToken
-//                + "&name=" + URLEncoder.encode(name, StandardCharsets.UTF_8)
-//                + "&userId=" + userId;

-        // log.info("[OAuth2 Redirect] {}", redirectUrl);

        getRedirectStrategy().sendRedirect(request, response, redirectUrl);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d06ce36 and eba8b21.

📒 Files selected for processing (3)
  • backend/src/main/java/org/sejongisc/backend/common/auth/config/CustomOAuth2UserService.java (1 hunks)
  • backend/src/main/java/org/sejongisc/backend/common/auth/config/OAuth2SuccessHandler.java (1 hunks)
  • backend/src/main/java/org/sejongisc/backend/common/auth/config/SecurityConfig.java (1 hunks)
🔇 Additional comments (3)
backend/src/main/java/org/sejongisc/backend/common/auth/config/CustomOAuth2UserService.java (1)

46-48: 로깅 개선이 적절합니다.

OAuth2 속성을 디버그 레벨로 변경하여 프로덕션 환경에서 불필요한 로그 출력을 줄이고, 민감할 수 있는 사용자 정보의 노출을 방지합니다.

backend/src/main/java/org/sejongisc/backend/common/auth/config/OAuth2SuccessHandler.java (1)

78-84: Refresh 쿠키 설정은 적절합니다.

Refresh 쿠키의 설정(HttpOnly, Secure, SameSite=None, 2주 만료)은 보안 모범 사례를 따르고 있습니다. Access 쿠키 버그가 수정되면 이 구성은 정상적으로 작동할 것입니다.

backend/src/main/java/org/sejongisc/backend/common/auth/config/SecurityConfig.java (1)

88-92: 원본 리뷰 의견이 부정확합니다.

제공된 보안 설정은 실제로 충돌이 없습니다. Spring Security는 인가 규칙을 순서대로 평가합니다:

  1. 라인 82-83의 permitAll() 규칙이 먼저 적용/api/user/id/find, /api/user/password/reset/**에 매칭
  2. 라인 90의 authenticated() 규칙이 그 다음 적용 → 나머지 /api/user/**에 매칭

실제 엔드포인트 검증 결과:

  • /api/user/details@AuthenticationPrincipal 사용 (인증 필요) ✓ 보안 규칙과 일치
  • /api/user/{userId} → 인증 필요 ✓ 보안 규칙과 일치
  • /api/user/id/find → 공개 엔드포인트 ✓ permitAll 목록에 포함
  • /api/user/password/reset/* → 공개 엔드포인트 ✓ permitAll 목록에 포함

현재 설정은 Spring Security의 표준 패턴을 따르고 있으며, 의도한 대로 작동합니다. 변경이 필요하지 않습니다.

Likely an incorrect or invalid review comment.

@Kosw6 Kosw6 merged commit 30f9df4 into main Nov 14, 2025
1 check passed
@Kosw6 Kosw6 deleted the SISC1-209-BE-redirect-url-프론트로-전달 branch November 14, 2025 09:07
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.

2 participants