[refactor] userID, password 조건 변경#1242
Conversation
--- 최소 8자 (상한 없음) 영문자 1개 이상 + 숫자 1개 이상 필수 공백 문자 불가 특수문자는 허용, 필수 아님, 종류 제한 없음 null/빈 문자열 불가
--- 길이: 5~20자 필수 포함: 소문자 1개 이상 숫자: 선택 특수문자: 선택 (! @ # $ ~만 허용) 허용 문자 전체: 영문 대소문자, 숫자, !@#$~ 공백/기타 특수문자(^, *, % 등) 불가
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning
|
| Cohort / File(s) | Summary |
|---|---|
비밀번호 검증 로직 완화 backend/src/main/java/moadong/global/validator/PasswordValidator.java, backend/src/main/java/moadong/user/entity/User.java, backend/src/main/java/moadong/user/view/UserSwaggerView.java |
비밀번호 정규식에서 특수문자([!@#$%^]) 요구사항 제거 및 최대 길이(20자) 제약 제거. 최소 8자 이상, 최소 하나의 문자와 숫자 포함 조건 유지. User 엔티티의 @Size 제약조건과 Swagger 문서 일관되게 업데이트. |
사용자 ID 검증 패턴 변경 backend/src/main/java/moadong/global/validator/UserIdValidator.java |
USER_ID_PATTERN에서 숫자 필수 요구사항 제거. 최소 하나의 소문자 필수, 길이 5–20자, 허용 문자 [A-Za-z0-9!@#$~] 유지. |
검증 테스트 업데이트 backend/src/test/java/moadong/unit/user/PasswordValidatorTest.java, backend/src/test/java/moadong/unit/user/UserRegisterTest.java |
PasswordValidatorTest를 매개변수화 테스트로 전환하여 다양한 비밀번호 사례 검증. UserRegisterTest에서 유효한 userId 테스트 케이스 추가 및 검증 규칙 설명 업데이트. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
- fix: 잘못된 비밀번호 검증 로직과 잘못된 비밀번호 테스트 수정 #467: PasswordValidator 및 관련 테스트를 수정하여 비밀번호 검증 규칙을 변경하는 PR과 동일 파일 수정
- [refactor & test] 유저 정보 컬렉션 통합 및 테스트 코드 작성(윤성원) #385: PasswordValidator, UserIdValidator, User 엔티티 및 관련 테스트를 수정하여 검증 로직을 변경하는 PR과 동일 범위의 변경사항
- [feature] 비밀번호 변경 시 아이디/이전 비밀번호 동일 여부 검증 추가하고 초기화 api 비인증 사용자에게 제공한다 #728: 비밀번호 검증 제약조건을 다루는 PR과 유관하며,
@Password어노테이션 사용 방식 변경과 검증자 의존성 관련
Suggested labels
✅ Test
Suggested reviewers
- PororoAndFriends
- Due-IT
- Zepelown
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | 풀 리퀘스트 제목은 주요 변경 사항을 명확하게 요약하고 있습니다. '[refactor] userID, password 조건 변경'은 userId와 password 검증 규칙 변경이라는 핵심 내용을 간결하고 구체적으로 전달합니다. |
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
- 📝 Generate docstrings (stacked PR)
- 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
refactor/#1241-id-password-condition-change-MOA-682
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 @coderabbitai help to get the list of available commands and usage tips.
Test Results94 tests 94 ✅ 16s ⏱️ Results for commit f852901. |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
backend/src/test/java/moadong/unit/user/UserRegisterTest.java (1)
179-183:⚠️ Potential issue | 🟡 Minor에러 메시지 복사-붙여넣기 오류
회원가입시_유저_비밀번호가_조건에_맞지_않으면_실패한다메서드 내에서"유효하지 않은 userId: " + userId라는 메시지를 출력합니다. 파라미터는password이므로 메시지와 변수 모두 수정이 필요합니다.🐛 수정 제안
- fail("예외나 검증 실패가 발생하지 않았습니다. 유효하지 않은 userId: " + userId); + fail("예외나 검증 실패가 발생하지 않았습니다. 유효하지 않은 password: " + password);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@backend/src/test/java/moadong/unit/user/UserRegisterTest.java` around lines 179 - 183, In the test method 회원가입시_유저_비밀번호가_조건에_맞지_않으면_실패한다 in UserRegisterTest.java update the failure message and variable used: replace the string concatenation that currently says "유효하지 않은 userId: " + userId with the correct parameter and variable for this test, e.g. "유효하지 않은 password: " + password, and ensure any reference to the variable userId in that fail() call is changed to password so the message and variable match the test's intent.
🧹 Nitpick comments (1)
backend/src/main/java/moadong/user/entity/User.java (1)
43-45: 엔티티@Size제약은 실질적으로 무효
password필드에 붙은@Size(min = 8)은 BCrypt로 인코딩된 해시(항상 60자)에 대해 검증되므로 항상 통과합니다. 실제 정책 강제는UserRegisterRequest의@Password검증기에서 이루어집니다. 엔티티 레벨 제약은 불필요하거나, 의도가 있다면 주석으로 명시하는 것이 좋습니다.♻️ 불필요한 `@Size` 제약 제거 제안
`@NotNull` - `@Size`(min = 8) private String password;🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@backend/src/main/java/moadong/user/entity/User.java` around lines 43 - 45, 엔티티 User의 password 필드에 있는 `@Size`(min = 8) 제약은 BCrypt 해시(항상 ~60자)에 대해 항상 통과하므로 실효가 없습니다; UserRegisterRequest의 `@Password` 검증기에서 실제 정책을 적용하므로 User.password의 `@Size` 주석을 제거하거나(권장) 해당 의도가 있다면 User 클래스의 password 필드 위에 주석으로 의도와 이유를 명시하세요 (참조: class User, field password 및 UserRegisterRequest/@Password validator).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@backend/src/main/java/moadong/user/view/UserSwaggerView.java`:
- Around line 23-26: Update the Swagger documentation string in
UserSwaggerView.java to refer to "아이디" instead of "이메일" so it matches the actual
validation logic in UserRegisterRequest and UserCommandService; specifically
replace the phrase "이메일과 동일한 비밀번호 불가" with "아이디와 동일한 비밀번호 불가" to align with the
PASSWORD_SAME_AS_USERID error code and related tests.
In `@backend/src/test/java/moadong/unit/user/UserRegisterTest.java`:
- Around line 164-169: The test includes UserFixture.collectUserId ("test1112")
in the invalid-password cases but that value now matches the relaxed
PasswordValidator regex (^(?=.*[a-zA-Z])(?=.*[0-9])(?!.*\\s).{8,}$), so the test
fails; update the parameter set in UserRegisterTest to remove
UserFixture.collectUserId or replace it with a truly invalid password (e.g., no
digits, no letters, or contains whitespace) so the violations assertion behaves
as intended and references remain clear (UserRegisterTest,
UserFixture.collectUserId, PasswordValidator).
- Around line 128-131: The test uses UserFixture.collectPassword ("test1112@")
which actually satisfies UserIdValidator's pattern and makes the test
unexpectedly pass; update the test in UserRegisterTest to remove this misleading
case or replace UserFixture.collectPassword with a truly invalid value (e.g., a
string containing a character not in [!@#$~] such as '%' or '^' or '*'),
ensuring the failing-case list contains an input that will not match the regex
so violations.isEmpty() will be false.
---
Outside diff comments:
In `@backend/src/test/java/moadong/unit/user/UserRegisterTest.java`:
- Around line 179-183: In the test method 회원가입시_유저_비밀번호가_조건에_맞지_않으면_실패한다 in
UserRegisterTest.java update the failure message and variable used: replace the
string concatenation that currently says "유효하지 않은 userId: " + userId with the
correct parameter and variable for this test, e.g. "유효하지 않은 password: " +
password, and ensure any reference to the variable userId in that fail() call is
changed to password so the message and variable match the test's intent.
---
Nitpick comments:
In `@backend/src/main/java/moadong/user/entity/User.java`:
- Around line 43-45: 엔티티 User의 password 필드에 있는 `@Size`(min = 8) 제약은 BCrypt 해시(항상
~60자)에 대해 항상 통과하므로 실효가 없습니다; UserRegisterRequest의 `@Password` 검증기에서 실제 정책을 적용하므로
User.password의 `@Size` 주석을 제거하거나(권장) 해당 의도가 있다면 User 클래스의 password 필드 위에 주석으로 의도와
이유를 명시하세요 (참조: class User, field password 및 UserRegisterRequest/@Password
validator).
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Jira integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (6)
backend/src/main/java/moadong/global/validator/PasswordValidator.javabackend/src/main/java/moadong/global/validator/UserIdValidator.javabackend/src/main/java/moadong/user/entity/User.javabackend/src/main/java/moadong/user/view/UserSwaggerView.javabackend/src/test/java/moadong/unit/user/PasswordValidatorTest.javabackend/src/test/java/moadong/unit/user/UserRegisterTest.java
#️⃣연관된 이슈
📝작업 내용
참고자료
https://item4.blog/2023-09-20/password-the-right-way/
기존의 id,password의 조건이 과하게 강하게 설정되어있다 판단되어 완화하였습니다
UserId5~20자소문자 1개 이상! @ # $ ~만 허용)!@#$~^,*,%등) 불가Password8자 이상(상한 없음)영문 1개 이상+숫자 1개 이상중점적으로 리뷰받고 싶은 부분(선택)
논의하고 싶은 부분(선택)
🫡 참고사항
Summary by CodeRabbit
릴리스 노트