feat(auth): REST Body class-validator DTO 도입 (Auth 3종)#97
Conversation
기존 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
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Coverage report
Test suite run success950 tests passing in 86 suites. Report generated by 🧪jest coverage report action from bbd2f26 |
There was a problem hiding this comment.
💡 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, |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
/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의 수동 검증(빈 문자열 / 강 비밀번호 정책) 제거 +assertStrongPasswordprivate 메서드 삭제. 책임이 DTO 레이어로 완전 이전IsStrongPassword커스텀 validator 추가 (src/common/validators/)배경 / Plan 연결
FE 영향 (사전 협의 필요)
빈 입력 / 잘못된 형식에 대해 다음 엔드포인트의 응답 상태코드가 변경됩니다 (정상 입력은 동일):
POST /auth/seller/loginPOST /auth/seller/change-passwordPOST /auth/dev/issue-token상세 협의 사항(룰별 Before/After 응답 예시, FE 액션 체크리스트)은 별도 공유 예정.
후속 작업 (별도 PR)
Test plan
yarn lint통과yarn test950/950 통과 (회귀 없음)yarn dto:check정상 (errors 0)npx tsc --noEmit통과