Conversation
Walkthrough새 사용자 익명 가입 응답에 userId 필드를 추가하고, 서비스에서 해당 값을 응답에 포함했습니다. 공통 ApiResponse의 isSuccess 직렬화를 게터로 옮겼습니다. Spring Security에 /error를 공개 허용으로 추가했습니다. prod 프로필에 Swagger 서버 정보를 설정했습니다. Changes
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)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
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 unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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,message도final로 두는 것을 고려해 볼 수 있습니다(선택).
📜 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.
📒 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 비교로 중복 필드나 누락이 없는지 한 번만 확인해 주세요.
| springdoc: | ||
| swagger-ui: | ||
| servers: | ||
| - url: https://api.napulnapul.com | ||
| description: Production Server |
There was a problem hiding this comment.
중대: 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.
hey
Summary by CodeRabbit