Skip to content

feat(auth): REST Body class-validator DTO 도입 (Auth 3종)#97

Merged
chanwoo7 merged 2 commits into
developfrom
refactor/auth-rest-dto
May 23, 2026
Merged

feat(auth): REST Body class-validator DTO 도입 (Auth 3종)#97
chanwoo7 merged 2 commits into
developfrom
refactor/auth-rest-dto

Conversation

@chanwoo7
Copy link
Copy Markdown
Member

@chanwoo7 chanwoo7 commented May 23, 2026

Summary

  • Auth REST 3개 엔드포인트(/auth/seller/login, /auth/seller/change-password, /auth/dev/issue-token)의 Body 를 class DTO + class-validator 로 전환
  • auth.controller.ts 인라인 interface 3종 제거. devIssueToken 의 inline 형식 체크 제거 (DTO 가 처리)
  • auth.service.changeSellerPassword 의 수동 검증(빈 문자열 / 강 비밀번호 정책) 제거 + assertStrongPassword private 메서드 삭제. 책임이 DTO 레이어로 완전 이전
  • 신규 IsStrongPassword 커스텀 validator 추가 (src/common/validators/)

배경 / Plan 연결

  • 출처: P0-3 단계 2 (Auth REST DTO) — 검증 전략 A-2 의 첫 도메인 적용
  • 전제: 직전 PR (DTO 검증 인프라 + 동기화 가드)

FE 영향 (사전 협의 필요)

빈 입력 / 잘못된 형식에 대해 다음 엔드포인트의 응답 상태코드가 변경됩니다 (정상 입력은 동일):

엔드포인트 Before After
POST /auth/seller/login 401 400 (ValidationPipe)
POST /auth/seller/change-password 400 (다른 메시지) 400 (DTO 표준 메시지)
POST /auth/dev/issue-token 400 (다른 메시지) 400 (DTO 표준 메시지)

상세 협의 사항(룰별 Before/After 응답 예시, FE 액션 체크리스트)은 별도 공유 예정.

후속 작업 (별도 PR)

  • P0-3 단계 3: User GraphQL Input 전수 DTO 화
  • P0-3 단계 4: Seller GraphQL Input 전수 DTO 화

Test plan

  • 로컬 yarn lint 통과
  • 로컬 yarn test 950/950 통과 (회귀 없음)
  • 로컬 yarn dto:check 정상 (errors 0)
  • npx tsc --noEmit 통과
  • CI: lint / type-check / test:cov 통과
  • CI: dto:check warning step 정상 종료
  • CI: codecov/patch (89.65% / target 80%) 통과

chanwoo7 added 2 commits May 24, 2026 02:47
기존 auth.service.assertStrongPassword(private) 의 길이 8~64 + 4종
문자 클래스 검증 로직을 DTO 레이어에서 재사용 가능한 데코레이터로
이전. trim 후 길이 판정으로 기존 동작 호환.

후속 PR 에서 SellerChangePasswordInput.newPassword 에 적용 +
service 측 assertStrongPassword 메서드 제거 예정.
A-2 검증 전략 P0-3 단계 2.

- SellerLoginInput / SellerChangePasswordInput / DevIssueTokenInput
  3종 class DTO 추가. ValidationPipe 가 정식 검증.
- auth.controller.ts: 인라인 interface 3종 제거, devIssueToken
  의 body 형식 체크 제거 (DTO 가 처리)
- auth.service.changeSellerPassword: 빈 문자열 / 강 비밀번호 정책
  수동 검증 제거. assertStrongPassword private 메서드 삭제. 검증은
  SellerChangePasswordInput 의 @IsStrongPassword 가 담당.
- service 단위 spec 정리: DTO 레이어로 이동한 검증 케이스 제거.
  도메인 분기(현재 비밀번호 불일치, 동일 비밀번호 거절 등)만 잔존.

FE 영향:
- 위 3개 엔드포인트가 빈 입력 / 잘못된 형식에 대해 401/500 → 400 으로
  정상화. 정상 입력은 응답 동일.
- 자세한 협의 사항은 docs/docs_260524_001050_fe-coord-1-rest-body-validation.md
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9b55ae90-f484-4598-a24d-7faa96b9cfdb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/auth-rest-dto

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 23, 2026

Codecov Report

❌ Patch coverage is 89.65517% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/features/auth/controllers/auth.controller.ts 50.00% 0 Missing and 3 partials ⚠️

📢 Thoughts on this report? Let us know!

@github-actions
Copy link
Copy Markdown

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 96.76% 2952/3051
🟢 Branches 86.47% 1662/1922
🟢 Functions 93.44% 627/671
🟢 Lines 97.07% 2686/2767

Test suite run success

950 tests passing in 86 suites.

Report generated by 🧪jest coverage report action from bbd2f26

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bbd2f26619

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Post('dev/issue-token')
async devIssueToken(
@Body() body: DevIssueTokenBody,
@Body() body: DevIssueTokenInput,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep dev-token production path returning Forbidden

Switching this parameter to a validated DTO makes malformed requests fail in the global ValidationPipe before devIssueToken() reaches its NODE_ENV==='production' guard, so production can now return 400 instead of the documented/previous 403 for this endpoint. I checked src/main.ts and the app uses a global ValidationPipe, which runs before handler logic; this changes behavior specifically for invalid bodies in production and can break callers/tests that rely on a consistent Forbidden response for all production access attempts.

Useful? React with 👍 / 👎.

@chanwoo7 chanwoo7 merged commit 90e8f25 into develop May 23, 2026
12 of 13 checks passed
@chanwoo7 chanwoo7 deleted the refactor/auth-rest-dto branch May 23, 2026 17:55
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.

1 participant