Skip to content

bug(#80) : /test 인가 제외#83

Merged
fixgramwork merged 1 commit intodevelopfrom
bug/#80
Sep 17, 2025
Merged

bug(#80) : /test 인가 제외#83
fixgramwork merged 1 commit intodevelopfrom
bug/#80

Conversation

@Hgyeol
Copy link
Member

@Hgyeol Hgyeol commented Sep 17, 2025

📌 PR 제목 규칙

[#81 ] 인가 제외


✅ 작업 내용

  • 인가 제외

🔗 관련 이슈

Close #81

📌 체크리스트

  • 코드 컨벤션을 지켰나요?
  • 커밋 메시지 컨벤션을 지켰나요?
  • 테스트를 완료했나요?

Summary by CodeRabbit

  • New Features
    • /test 엔드포인트를 공개로 추가하여 인증 없이 접근 가능합니다. 기존 공개 API(swagger 등)와 동일하게 사용할 수 있습니다.
  • Security
    • 세션 쿠키에 Secure 플래그를 활성화하고 SameSite=None을 적용했습니다. 이제 쿠키는 HTTPS에서만 전송되며, 크로스사이트 연동 시 로그인 세션 유지가 더욱 안정적입니다. 전반적인 인증 흐름과 기존 API 동작에는 영향이 없습니다.

@coderabbitai
Copy link

coderabbitai bot commented Sep 17, 2025

Walkthrough

보안 설정에서 "/test" 경로를 공개로 추가하고, 로그인 성공 시 쿠키의 Secure 속성을 활성화했습니다. 애플리케이션 설정에 세션 쿠키의 SameSite=None 및 secure=true를 추가했습니다. 사용자 등록 컨트롤러에는 사용되지 않는 @Autowired import가 추가되었습니다.

Changes

Cohort / File(s) Change Summary
공개 엔드포인트 조정
src/main/java/.../global/config/SecurityConfig.java
"/test"permitAll 목록에 추가하여 인증 없이 접근 가능하도록 변경.
쿠키 보안 속성 강화
src/main/java/.../global/config/CustomSuccessHandler.java, src/main/resources/application.yaml
로그인 성공 시 쿠키에 setSecure(true) 활성화. 세션 쿠키 설정에 same-site: none, secure: true 추가.
컨트롤러 경미 변경
src/main/java/.../domain/user/presentation/RegisterController.java
@Autowired import만 추가(미사용), 동작 변화 없음.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor C as Client
    participant SF as SecurityFilterChain
    participant TC as TestController (/test)

    C->>SF: GET /test (Unauthenticated)
    rect rgba(200,230,255,0.3)
    note right of SF: "/test"가 permitAll
    SF-->>C: Allow without auth
    end
    SF->>TC: Forward request
    TC-->>C: 200 OK (response)
Loading
sequenceDiagram
    autonumber
    actor U as User
    participant OAuth as OAuth2 Login
    participant SH as CustomSuccessHandler
    participant R as Response

    U->>OAuth: Complete OAuth2 login
    OAuth-->>SH: onAuthenticationSuccess
    rect rgba(220,255,220,0.3)
    SH->>R: Set cookie (HttpOnly, Secure=true, MaxAge=7d, Path="/")
    note right of R: Session cookie: SameSite=None, Secure=true (application.yaml)
    end
    R-->>U: Redirect / success response
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Feat/#51 #70: "/test" 엔드포인트 구현/변경과 직접 연관되어 보안 설정의 공개 경로 추가와 맞물림.
  • bug(#80) : session 오류 해결 #81: SecurityConfig 분리/개편과 apiChain 동작 변경이 본 PR의 공개 경로 추가와 동일 영역 충돌 가능.
  • Fix#78 #79: CustomSuccessHandler와 RegisterController를 함께 수정하여 쿠키/세션 처리 관점에서 코드 레벨 연관.

Suggested labels

개발

Poem

새벽 서버, 토끼는 깡총 뛰네 🐇
“/test” 길은 활짝, 누구나 오라 하네—
쿠키는 단단히, Secure로 채우고
SameSite=None, 세션도 준비 완료!
작은 한 줄 import, 바람처럼 스쳐가네.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning PR에 RegisterController에 사용되지 않는 import(org.springframework.beans.factory.annotation.Autowired)가 추가된 점은 기능적 변화가 없는 불필요한(범위 외) 변경으로 보입니다; 반면 CustomSuccessHandler의 쿠키 secure 활성화와 application.yaml의 same-site/secure 추가, SecurityConfig의 '/test' 인가 제외는 연결된 세션 이슈와 관련성이 있습니다. 미사용 import를 제거하고 코드 스타일 검사(lint)와 빌드 검증을 통과시킨 후 PR을 업데이트하며, PR 설명에 각 변경의 목적과 영향(특히 '/test' 인가 제외의 이유)을 명확히 기재해 불필요한 변경이 포함되지 않도록 정리해 주세요.
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.
Linked Issues Check ❓ Inconclusive 링크된 이슈 #81은 세션 오류 해결을 목표로 로그인·API 보안 흐름 분리, 로그인 경로의 세션 사용·API의 무상태 유지, 로그아웃 시 리프레시 토큰 무효화 등 구체적 코드 변경을 요구합니다. PR은 CustomSuccessHandler에서 쿠키를 secure로 활성화하고 application.yaml에 same-site·secure 설정을 추가하며 '/test' 경로를 인가 제외로 설정하는 등 세션·쿠키 관련 일부 변경을 포함하지만 보안 체인 리팩터나 세션 정책 전환, JWT 필터 연계 수정 및 관련 테스트 증빙 등 이슈의 핵심 기술 요구는 반영되어 있지 않습니다. 따라서 이슈의 모든 코딩 요구를 충족했는지 판정할 수 없어 현재 상태로는 확증적 합격을 내리기 어렵습니다. 로그인/API 보안 흐름 분리와 세션 정책의 명시적 적용, JWT 필터 연계 확인 및 로그아웃 시 리프레시 토큰 무효화 같은 핵심 항목을 SecurityConfig 및 관련 클래스에 구현하고 관련 단위/통합 테스트 결과를 PR에 첨부한 뒤 재검토 요청하시기 바랍니다.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed PR 제목 "bug(#80) : /test 인가 제외"는 변경된 주요 내용인 보안 설정에서 '/test' 경로를 인가 제외한 점을 직접적으로 요약하고 있어 간결하고 관련성이 높습니다.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug/#80

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/hello/cluebackend/global/config/CustomSuccessHandler.java (1)

70-78: refresh_token 쿠키에 SameSite=None 누락 — 크로스사이트 전송 실패 가능

server.servlet.session.cookie.same-site: none은 JSESSIONID에만 적용됩니다. 여기서 직접 생성하는 refresh_token 쿠키는 jakarta.servlet.http.Cookie로는 SameSite를 설정할 수 없어, 크로스 도메인 환경에서 브라우저가 쿠키를 보내지 않을 수 있습니다. Secure 활성화는 잘 추가되었지만 SameSite=None도 함께 포함해야 합니다. ResponseCookie로 전환해 Set-Cookie 헤더를 직접 추가하는 방식을 권장합니다.

아래 변경으로 SameSite=None을 명시하세요(호출부도 함께 수정 필요).

-    private Cookie createCookie(String key, String value) {
-        Cookie cookie = new Cookie(key, value);
-        cookie.setMaxAge(7 * 24  * 60 * 60);
-        cookie.setSecure(true);
-        cookie.setPath("/");
-        cookie.setHttpOnly(true);
-
-        return cookie;
-    }
+    private String createCookie(String key, String value) {
+        ResponseCookie cookie = ResponseCookie.from(key, value)
+                .httpOnly(true)
+                .secure(true)
+                .sameSite("None")
+                .path("/")
+                .maxAge(Duration.ofDays(7))
+                .build();
+        return cookie.toString();
+    }

호출부(Line 64) 예시 수정:

// imports: org.springframework.http.ResponseCookie; java.time.Duration;
response.addHeader("Set-Cookie", createCookie("refresh_token", refresh));

참고: 개발 환경이 HTTPS가 아니면(예: http://localhost) Secure 쿠키는 세팅/전송되지 않습니다.

🧹 Nitpick comments (2)
src/main/java/hello/cluebackend/domain/user/presentation/RegisterController.java (1)

10-10: 불필요한 import 제거

@Autowired를 사용하지 않습니다. 정리해 주세요.

- import org.springframework.beans.factory.annotation.Autowired;
src/main/java/hello/cluebackend/global/config/SecurityConfig.java (1)

84-88: 로그아웃 시 삭제 쿠키 속성 일치 권장

원쿠키가 Secure(그리고 SameSite=None)라면 삭제 쿠키도 동일 속성으로 설정하는 편이 안전합니다. ResponseCookie로 삭제 헤더를 내려 일관성을 맞추는 것을 권장합니다.

예시:

response.addHeader("Set-Cookie",
  ResponseCookie.from("refresh_token", "")
    .path("/")
    .httpOnly(true)
    .secure(true)
    .sameSite("None")
    .maxAge(0)
    .build()
    .toString()
);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d830414 and 5d4e197.

📒 Files selected for processing (4)
  • src/main/java/hello/cluebackend/domain/user/presentation/RegisterController.java (1 hunks)
  • src/main/java/hello/cluebackend/global/config/CustomSuccessHandler.java (1 hunks)
  • src/main/java/hello/cluebackend/global/config/SecurityConfig.java (1 hunks)
  • src/main/resources/application.yaml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-08T23:38:29.680Z
Learnt from: fixgramwork
PR: EscapeFrame/clueBackend#23
File: src/main/java/hello/cluebackend/domain/user/service/RegisterUserService.java:17-23
Timestamp: 2025-07-08T23:38:29.680Z
Learning: This project uses OAuth2 authentication and does not require traditional password storage or validation. The RegisterUserService in src/main/java/hello/cluebackend/domain/user/service/RegisterUserService.java should not store passwords since OAuth2 handles authentication externally.

Applied to files:

  • src/main/java/hello/cluebackend/domain/user/presentation/RegisterController.java
🔇 Additional comments (2)
src/main/java/hello/cluebackend/global/config/SecurityConfig.java (1)

98-100: /test 공개 허용 범위 확인

의도가 단일 엔드포인트 공개라면 현재(/test)로 충분합니다. 하위 경로까지 공개하려면 "/test/**"로 명시해야 합니다. 의도 확인 부탁드립니다.

src/main/resources/application.yaml (1)

76-81: SameSite=None + Secure 설정 적절 — Spring Boot 3.4.4 확인; dev 환경 HTTPS 적용 필요

build.gradle에서 'org.springframework.boot' 플러그인 버전 '3.4.4'로 확인되어 SameSite=None 지원(2.6+)은 충족됩니다.
src/main/resources/application.yaml (lines 76–81): JSESSIONID에 same-site: none 및 secure: true 설정이 적용되어 있으나, 개발 환경에서 HTTPS 미사용 시 세션 쿠키가 전송되지 않아 인증 흐름이 깨질 수 있으니 dev에서 HTTPS 사용(예: 로컬 리버스 프록시) 또는 프로파일별 쿠키 설정 분리 적용.
커스텀 refresh_token 쿠키는 별도 처리 필요.

@fixgramwork fixgramwork merged commit cadbdd8 into develop Sep 17, 2025
1 check passed
@coderabbitai coderabbitai bot mentioned this pull request Sep 25, 2025
5 tasks
@fixgramwork fixgramwork deleted the bug/#80 branch November 19, 2025 06:49
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