Skip to content

Refactor/lejuhooo#78

Merged
xoruddl merged 3 commits intodevelopfrom
refactor/lejuhooo
Aug 24, 2025
Merged

Refactor/lejuhooo#78
xoruddl merged 3 commits intodevelopfrom
refactor/lejuhooo

Conversation

@lejuho
Copy link
Collaborator

@lejuho lejuho commented Aug 24, 2025

hey

Summary by CodeRabbit

  • 신기능
    • 익명 회원 가입 응답에 userId가 추가되어 클라이언트에서 사용자 식별이 가능해졌습니다.
  • 버그 수정
    • 인증 없이 에러 엔드포인트(/error)에 접근 가능해져 오류 화면/응답 확인이 원활해졌습니다.
  • 문서화

@coderabbitai
Copy link

coderabbitai bot commented Aug 24, 2025

Walkthrough

새 사용자 익명 가입 응답에 userId 필드를 추가하고, 서비스에서 해당 값을 응답에 포함했습니다. 공통 ApiResponse의 isSuccess 직렬화를 게터로 옮겼습니다. Spring Security에 /error를 공개 허용으로 추가했습니다. prod 프로필에 Swagger 서버 정보를 설정했습니다.

Changes

Cohort / File(s) Summary of changes
Member auth DTO update
src/main/java/.../domain/member/auth/dto/response/AnonymousRegistrationResponse.java
userId: Long 필드 추가. Lombok @Getter/@builder로 게터와 빌더 메서드 생성. 전체 생성자 시그니처에 userId 포함.
Registration response wiring
src/main/java/.../domain/member/auth/service/AuthService.java
신규 사용자 등록 플로우에서 응답 빌더에 .userId(newUser.getId()) 추가.
ApiResponse accessor change
src/main/java/.../global/common/ApiResponse.java
클래스 레벨 @Getter 제거, 필드별 게터 추가. isSuccess() 공개 메서드 신설 및 @JsonProperty("isSuccess")를 게터에 부여. 직렬화 키 유지.
Security whitelist tweak
src/main/java/.../global/config/SecurityConfig.java
permitAll 목록에 "/error" 추가.
Prod Swagger server config
src/main/resources/application.yml
prod 프로필에 springdoc.swagger-ui.servershttps://api.napulnapul.com 서버 항목 추가.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant C as Client
    participant A as AuthService
    participant R as UserRepository(DB)
    participant T as TokenProvider

    C->>A: registerNewUser(request)
    A->>R: save(new User from request)
    R-->>A: newUser(id, ...)
    A->>T: createAccessToken(newUser)
    T-->>A: accessToken
    A->>T: createRefreshToken(newUser)
    T-->>A: refreshToken
    note right of A: Build AnonymousRegistrationResponse<br/>with accessToken, refreshToken,<br/>userId, nickname, isNewUser
    A-->>C: ApiResponse.onSuccess(AnonymousRegistrationResponse)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • c5ln

Poem

토끼 키보드 톡톡, 밤새 코드를 빚네 🐇
응답에 ID 한 알, 별처럼 반짝이네 ✨
성공은 게터로, 진실을 말하도다
오류 문도 활짝, 안전히 지나가세
프로드의 별자리, 스웨거에 새겨두네 🌌

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/lejuhooo

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.
    • 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.
  • 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 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/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@xoruddl xoruddl merged commit 6570c49 into develop Aug 24, 2025
5 of 6 checks passed
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 (7)
src/main/java/com/example/cp_main_be/global/config/SecurityConfig.java (1)

44-46: H2 콘솔은 로컬에서만 노출되도록 조건부 허용 권장

현재 전역으로 "/h2-console/**"를 permitAll 하고 있습니다. prod 환경에는 H2 콘솔이 없더라도, 보안 정책 측면에서 로컬 프로필에서만 허용되도록 제한하는 편이 안전합니다.

아래와 같이 프로퍼티 기반으로 조건부 허용을 적용하는 접근을 고려해 주세요(예시):

// 예시: 프로퍼티 기반 조건부 허용
@Value("${spring.h2.console.enabled:false}")
private boolean h2ConsoleEnabled;

http.authorizeHttpRequests(authorize -> {
  authorize
      .requestMatchers(
          "/api/v1/auth/signup",
          "/api/v1/auth/refresh",
          "/api/v1/policy",
          "/swagger-ui/**",
          "/v3/api-docs/**",
          "/swagger-resources/**",
          "/error"
      ).permitAll();
  if (h2ConsoleEnabled) {
    authorize.requestMatchers("/h2-console/**").permitAll();
  }
  authorize.anyRequest().authenticated();
});

로컬 application.yml에서만 spring.h2.console.enabled: true를 두고, 다른 프로필에서는 기본값(false)을 사용하면 됩니다.

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

75-79: prod 프로필에서 Swagger UI 서버 정보를 추가하셨습니다 — 운영 노출 의도 확인 필요

SecurityConfig에서 /swagger-ui/**, /v3/api-docs/**가 전역 permitAll인 상태라 prod에서도 문서가 공개됩니다. 의도된 정책이라면 OK, 아니라면 prod에서는 UI/스펙 비공개(또는 인증 보호)로 전환하세요.

운영 비공개 예시:

springdoc:
  api-docs:
    enabled: false  # prod에서는 스펙 비활성화
  swagger-ui:
    enabled: false  # prod에서는 UI 비활성화
# 필요한 경우 별도 관리자 인증 뒤 리버스 프록시로만 노출

운영에서 공개가 필요하다면 최소 IP/BasicAuth/게이트웨이 인증 등 보호 수단을 덧붙이길 권장합니다.

src/main/java/com/example/cp_main_be/domain/member/auth/dto/response/AnonymousRegistrationResponse.java (3)

12-12: userId 필드 추가에 따른 API 호환성 영향 점검

응답 스키마가 바뀌었으므로(숫자형 userId 추가) 이를 소비하는 클라이언트(앱/프론트)에서 파싱 기대치가 깨지지 않는지 확인이 필요합니다. 응답 예시/스웨거 스키마도 업데이트해 주세요.

필요하시면 OpenAPI 스키마/샘플 응답 패치도 같이 제안드리겠습니다.


12-12: DB PK 노출 여부 재검토: 외부 식별자로 UUID 사용 고려

증분형 PK(Long)를 외부에 노출하면 유저 수 추정·열거 가능성이 생길 수 있습니다. 클라이언트가 내부 PK가 꼭 필요한 것이 아니라면, 외부 식별자로 uuid를 노출하거나 둘 다 제공하되 클라이언트는 uuid를 사용하도록 가이드하는 방안을 권장합니다.


13-15: 주석 정정 제안: 닉네임 생성 로직 제거에 맞게 텍스트 업데이트

현재 주석이 “생성된 닉네임”으로 되어 있으나, 서비스 로직은 요청받은 닉네임을 그대로 사용하고 있습니다. 혼동 방지를 위해 주석을 업데이트해 주세요.

다음과 같이 변경 제안:

-  private final String nickname; // [추가] 생성된 닉네임
+  private final String nickname; // 가입 시 입력한 닉네임
src/main/java/com/example/cp_main_be/domain/member/auth/service/AuthService.java (1)

96-121: ID 할당 시점 안전성 확보: save 반환 엔티티로 ID 사용

save(newUser) 직후 newUser.getId()는 JPA 전략에 따라 null일 수 있습니다(특히 flush 타이밍 이슈). save가 반환한 엔티티를 사용해 ID를 참조하는 편이 안전합니다.

다음 변경을 권장합니다:

-    userRepository.save(newUser);
+    User savedUser = userRepository.save(newUser);

@@
-    return AnonymousRegistrationResponse.builder()
+    return AnonymousRegistrationResponse.builder()
         .accessToken(accessToken)
         .refreshToken(refreshToken)
-        .userId(newUser.getId())
+        .userId(savedUser.getId())
         .nickname(nickname) // 생성된 닉네임 반환
         .isNewUser(true)
         .build();

또한 닉네임의 유효성(Null/Blank/중복) 검증이 상위 계층에서 보장되는지 확인 부탁드립니다. 필요 시 이 메서드 초입에서 명시 검증을 추가하는 것도 고려해 주세요.

src/main/java/com/example/cp_main_be/global/common/ApiResponse.java (1)

17-27: Jackson 애노테이션 일관성 정리(경미한 개선사항)

현재 필드(code, message, result)에 @JsonProperty가 있고, Lombok 게터도 존재합니다. Jackson은 기본적으로 게터 기반 바인딩을 사용하므로 필드 애노테이션은 불필요합니다. 중복 메타데이터를 줄여 가독성을 높일 수 있습니다.

다음과 같이 필드의 @JsonProperty만 제거해도 동작은 동일합니다:

-  @Getter
-  @JsonProperty("code")
+  @Getter
   private String code;

-  @Getter
-  @JsonProperty("message")
+  @Getter
   private String message;

-  @Getter
-  @JsonProperty("result")
+  @Getter
   private final T result;

추가로 이 DTO는 생성 이후 불변 객체로 쓰이는 만큼 isSuccess, code, messagefinal로 두는 것을 고려해 볼 수 있습니다(선택).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 635dd99 and 742b509.

📒 Files selected for processing (5)
  • src/main/java/com/example/cp_main_be/domain/member/auth/dto/response/AnonymousRegistrationResponse.java (1 hunks)
  • src/main/java/com/example/cp_main_be/domain/member/auth/service/AuthService.java (1 hunks)
  • src/main/java/com/example/cp_main_be/global/common/ApiResponse.java (1 hunks)
  • src/main/java/com/example/cp_main_be/global/config/SecurityConfig.java (1 hunks)
  • src/main/resources/application.yml (1 hunks)
🔇 Additional comments (2)
src/main/java/com/example/cp_main_be/global/config/SecurityConfig.java (1)

44-46: /error 공개 허용 추가는 적절합니다

스프링 기본 오류 경로를 인증 없이 열어 401→/error 무한 루프를 방지하는 설정으로 타당합니다. 기존 필터 체인 구성과도 충돌 없어 보입니다.

src/main/java/com/example/cp_main_be/global/common/ApiResponse.java (1)

29-32: isSuccess 직렬화를 게터로 이동한 변경은 합리적입니다

JSON 키를 isSuccess로 유지하면서 내부 필드를 은닉하는 의도가 명확해졌습니다. 기존 소비자가 isSuccess 필드를 그대로 읽는 경우에도 호환될 가능성이 높습니다.

배포 전/후 스냅샷 JSON 비교로 중복 필드나 누락이 없는지 한 번만 확인해 주세요.

Comment on lines +75 to +79
springdoc:
swagger-ui:
servers:
- url: https://api.napulnapul.com
description: Production Server
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

중대: prod 프로필에서 JPA DDL 옵션이 create-drop으로 설정되어 있습니다

같은 prod 블록(라인 69–71)에 ddl-auto: create-drop이 존재합니다. 이는 애플리케이션 시작/종료 시 스키마를 생성/삭제해 운영 데이터 손실을 유발할 수 있는 치명적 설정입니다. 즉시 none 또는 validate로 변경해 주세요.

다음과 같이 정정 권장(예시):

spring:
  jpa:
    hibernate:
      ddl-auto: none   # 또는 validate
    show-sql: false

마이그레이션은 전용 툴(Flyway/Liquibase)로 관리하는 것을 권장합니다.

🤖 Prompt for AI Agents
In src/main/resources/application.yml around lines 75 to 79 (and specifically
the prod profile block at lines ~69–71), the JPA ddl-auto is set to create-drop
which will create and then drop the schema on app lifecycle; change ddl-auto to
none or validate in the prod profile (e.g., set spring.jpa.hibernate.ddl-auto:
none or validate and ensure show-sql: false), persist the change in the YAML
prod block, and document that schema migrations should be managed by a dedicated
tool like Flyway or Liquibase.

@lejuho lejuho deleted the refactor/lejuhooo branch August 25, 2025 08:11
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