-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ 인증코드 검증 및 회원가입 토큰 발급 로직 작성 #16
Conversation
Walkthrough이 변경 사항은 인증 프로세스를 개선하기 위해 여러 파일에서 새로운 기능과 속성을 추가합니다. Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
🧹 Outside diff range and nitpick comments (8)
domain/src/main/kotlin/com/threedays/domain/auth/entity/AuthToken.kt (2)
1-7
: 간단하고 명확한 인터페이스 구조입니다.이 인터페이스는 인증 토큰을 위한 간단한 계약을 제공합니다. 다양한 인증 토큰 구현을 허용하면서도 일관된 인터페이스를 유지할 수 있게 해줍니다.
인터페이스의 목적을 설명하는 간단한 문서 주석을 추가하는 것이 좋을 것 같습니다. 예를 들어:
/** * 인증 토큰을 나타내는 인터페이스입니다. * 이 인터페이스를 구현하는 클래스는 문자열 형태의 토큰 값을 제공해야 합니다. */ interface AuthToken { // ... existing code ... }
5-5
:value
속성이 명확하게 정의되어 있습니다.
value
속성은 간단하고 직관적입니다. 하지만 더 구체적인 이름을 사용하면 코드의 가독성을 높일 수 있습니다.속성 이름을 더 구체적으로 변경하는 것을 고려해보세요. 예를 들어:
val tokenValue: String또는
val rawToken: String이렇게 하면 속성의 목적이 더 명확해질 수 있습니다.
support/common/src/main/kotlin/com/threedays/support/common/exception/NotFoundException.kt (1)
1-3
: 구현이 올바르며 개선 제안전반적인 구현은 정확하고 간결합니다. 다음과 같은 개선 사항을 고려해 보시기 바랍니다:
- 클래스에 KDoc 주석을 추가하여 이 예외의 사용 시기와 방법을 설명합니다.
- 이 클래스를 상속할 가능성이 있다면
open
키워드를 추가하는 것을 고려해 보세요.- 더 자세한 오류 보고를 위해
Throwable
원인 매개변수를 받는 보조 생성자를 추가할 수 있습니다.다음과 같이 코드를 개선할 수 있습니다:
package com.threedays.support.common.exception /** * 요청된 리소스를 찾을 수 없을 때 발생하는 예외입니다. * * @param message 예외에 대한 상세 메시지 * @param cause 이 예외의 원인 (선택적) */ open class NotFoundException : RuntimeException { constructor(message: String) : super(message) constructor(message: String, cause: Throwable) : super(message, cause) }application/src/main/kotlin/com/threedays/application/auth/vo/command/AuthCodeCommand.kt (1)
15-15
: 스타일 개선: 후행 쉼표 제거 고려코드의 일관성을 위해
code
속성 뒤의 후행 쉼표를 제거하는 것이 좋습니다.다음과 같이 수정하는 것을 고려해보세요:
data class Verify( val id: AuthCodeId, - val code: String, + val code: String )domain/src/main/kotlin/com/threedays/domain/auth/exception/AuthException.kt (3)
18-20
: LGTM! 약간의 개선 제안
RegisterTokenExpiredException
클래스가 잘 구현되었습니다. 에러 코드와 메시지가 일관성 있게 작성되었습니다.가독성을 높이기 위해 다음과 같이 메시지를 상수로 추출하는 것을 고려해 보세요:
companion object { private const val REGISTER_TOKEN_EXPIRED_MESSAGE = "회원 가입 토큰이 만료되었습니다." } data class RegisterTokenExpiredException( override val message: String = REGISTER_TOKEN_EXPIRED_MESSAGE ) : AuthException(1003, message)이렇게 하면 메시지를 쉽게 재사용하고 관리할 수 있습니다.
22-24
: LGTM! 약간의 개선 제안
InvalidRegisterTokenException
클래스가 잘 구현되었습니다. 에러 코드와 메시지가 일관성 있게 작성되었습니다.가독성을 높이기 위해 다음과 같이 메시지를 상수로 추출하는 것을 고려해 보세요:
companion object { private const val INVALID_REGISTER_TOKEN_MESSAGE = "유효하지 않은 회원 가입 토큰입니다." } data class InvalidRegisterTokenException( override val message: String = INVALID_REGISTER_TOKEN_MESSAGE ) : AuthException(1004, message)이렇게 하면 메시지를 쉽게 재사용하고 관리할 수 있습니다.
18-24
: 문서 업데이트 제안새로운 예외 클래스
RegisterTokenExpiredException
와InvalidRegisterTokenException
이 잘 구현되었습니다. 이러한 변경사항을 반영하기 위해 다음 작업을 고려해 보세요:
- 프로젝트의 예외 처리 가이드 또는 문서를 업데이트하여 이 새로운 예외들에 대한 설명을 추가합니다.
- 이 예외들을 사용하는 개발자들을 위한 사용 예시를 추가합니다.
- 필요한 경우, 관련된 테스트 케이스를 업데이트하거나 추가합니다.
이렇게 하면 팀원들이 새로운 예외들을 더 쉽게 이해하고 올바르게 사용할 수 있을 것입니다.
application/src/test/kotlin/com/threedays/application/auth/service/AuthCodeServiceTest.kt (1)
71-72
: 테스트 코드에서 반복되는 전화번호 상수화 제안테스트 케이스마다
"01012345678"
을 반복적으로 사용하고 있습니다. 해당 값을 상수로 선언하여 중복을 줄이고 코드의 유지보수성을 향상시키는 것을 권장합니다.적용 가능한 변경 사항 예시:
+ // 상단에 상수 선언 + val testPhoneNumber = "01012345678" // 각 테스트 케이스에서 수정 - phoneNumber = "01012345678", + phoneNumber = testPhoneNumber,Also applies to: 99-101, 120-122
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (12)
- application/src/main/kotlin/com/threedays/application/auth/config/AuthProperties.kt (1 hunks)
- application/src/main/kotlin/com/threedays/application/auth/port/inbound/CommandAuthCode.kt (1 hunks)
- application/src/main/kotlin/com/threedays/application/auth/service/AuthCodeService.kt (2 hunks)
- application/src/main/kotlin/com/threedays/application/auth/vo/command/AuthCodeCommand.kt (2 hunks)
- application/src/main/resources/application-application.yaml (1 hunks)
- application/src/test/kotlin/com/threedays/application/auth/service/AuthCodeServiceTest.kt (3 hunks)
- domain/src/main/kotlin/com/threedays/domain/auth/entity/AuthToken.kt (1 hunks)
- domain/src/main/kotlin/com/threedays/domain/auth/entity/RegisterToken.kt (1 hunks)
- domain/src/main/kotlin/com/threedays/domain/auth/exception/AuthException.kt (1 hunks)
- domain/src/main/kotlin/com/threedays/domain/auth/repository/AuthCodeRepository.kt (1 hunks)
- domain/src/test/kotlin/com/threedays/domain/auth/entity/RegisterTokenTest.kt (1 hunks)
- support/common/src/main/kotlin/com/threedays/support/common/exception/NotFoundException.kt (1 hunks)
🔇 Additional comments (14)
application/src/main/kotlin/com/threedays/application/auth/config/AuthProperties.kt (2)
7-8
: 변경 사항이 적절해 보입니다.
tokenSecret
속성이 추가되어 인증 관련 구성 옵션이 확장되었습니다. 이는 JWT 토큰 서명이나 암호화에 사용될 것으로 보입니다.
8-8
: 토큰 비밀의 안전한 처리를 확인하세요.
tokenSecret
과 같은 민감한 정보를 구성 속성으로 저장할 때는 보안에 주의해야 합니다. 다음 사항을 고려해 주세요:
- 프로덕션 환경에서는 환경 변수나 안전한 비밀 관리 시스템을 통해 이 값을 제공하세요.
- 로그나 오류 메시지에 이 값이 노출되지 않도록 주의하세요.
- 애플리케이션 내에서 이 값에 대한 접근을 제한하고, 필요한 경우에만 사용하세요.
다음 스크립트를 실행하여
tokenSecret
이 안전하게 처리되고 있는지 확인하세요:application/src/main/kotlin/com/threedays/application/auth/port/inbound/CommandAuthCode.kt (2)
5-5
: LGTM: 새로운 import 문이 올바르게 추가되었습니다.
RegisterToken
에 대한 import 문이 적절하게 추가되었으며, 기존의 도메인 계층 import 패턴을 따르고 있습니다.
10-10
: LGTM: 새로운 메서드가 적절하게 추가되었습니다. 구현 클래스 확인 필요.
verify
메서드가 인터페이스에 잘 추가되었습니다. 메서드 이름과 파라미터 타입이 명확하고 일관성 있게 작성되었습니다.다만, 이 변경으로 인해
CommandAuthCode
인터페이스를 구현하는 모든 클래스들이 영향을 받을 수 있습니다. 다음 스크립트를 실행하여 영향을 받는 구현 클래스들을 확인해 주세요:이 스크립트의 결과를 바탕으로 필요한 구현 클래스들을 업데이트했는지 확인해 주세요.
✅ Verification successful
검증 완료:
verify
메서드가 모든 구현 클래스에 적절히 추가되었습니다.
AuthCodeService.kt
와CommandAuthCode.kt
파일에서verify
메서드가 올바르게 구현되었습니다.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Find classes implementing CommandAuthCode interface echo "Classes implementing CommandAuthCode:" rg --type kotlin -l "class .+ : CommandAuthCode" echo "\nClasses implementing CommandAuthCode that might need updates:" rg --type kotlin -l "class .+ : CommandAuthCode" | xargs rg -L "fun verify\("Length of output: 856
application/src/main/kotlin/com/threedays/application/auth/vo/command/AuthCodeCommand.kt (1)
13-16
: LGTM: Verify 클래스 추가가 적절합니다.새로운
Verify
데이터 클래스의 추가는AuthCodeCommand
의 기능을 확장하는 데 적절해 보입니다. 속성들이 논리적으로 올바르며 Kotlin의 데이터 클래스 규칙을 잘 따르고 있습니다.domain/src/main/kotlin/com/threedays/domain/auth/repository/AuthCodeRepository.kt (2)
6-6
: 새로운 import 문이 올바르게 추가되었습니다.
NotFoundException
을 위한 import 문이 적절하게 추가되었습니다. 이는 새로 추가된 메서드에서 사용되는 예외를 처리하기 위해 필요합니다.
10-10
: 새로운get
메서드가 잘 구현되었습니다.NotFoundException
에 대한 추가 정보가 필요합니다.새로 추가된
get
메서드는 간결하고 효과적으로 구현되었습니다. Kotlin의 null-safe 호출 연산자와 Elvis 연산자를 잘 활용하고 있습니다.하나의 질문이 있습니다:
NotFoundException
이 커스텀 예외인지, 아니면 표준 라이브러리의 일부인지 확인해 주실 수 있나요? 만약 커스텀 예외라면, 이 예외 클래스에 대한 문서나 간단한 설명을 추가하는 것이 도움이 될 것 같습니다.다음 스크립트를 실행하여
NotFoundException
의 출처를 확인해 보겠습니다:✅ Verification successful
get
메서드 변경 사항 승인 및NotFoundException
확인됨
NotFoundException
은 커스텀 예외로 정의되어 있습니다. 해당 예외에 대한 설명이나 문서를 추가하면 코드의 가독성을 높이는 데 도움이 될 것 같습니다.
NotFoundException
클래스는support/common/src/main/kotlin/com/threedays/support/common/exception/NotFoundException.kt
에 위치하고 있습니다.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the source of NotFoundException # Test: Search for the NotFoundException class definition rg --type kotlin -g '!**/build/**' 'class NotFoundException'Length of output: 222
domain/src/main/kotlin/com/threedays/domain/auth/entity/RegisterToken.kt (1)
1-16
: 코드 품질 우수코드가 명확하며, 함수와 예외 처리가 적절하게 구현되어 있습니다. 전체적으로 특별한 문제점이 발견되지 않았습니다.
Also applies to: 27-47, 51-56
application/src/test/kotlin/com/threedays/application/auth/service/AuthCodeServiceTest.kt (6)
11-17
: 필요한 라이브러리 Import 추가 확인추가된 Import 문들이 테스트에 필요한 라이브러리들을 정확히 가져오고 있습니다.
23-23
: 테스트 클래스에 DisplayName 어노테이션 추가테스트 클래스에
@DisplayName
어노테이션을 추가하여 가독성을 높인 점이 좋습니다.
30-31
: 유효기간 변수를 도입하여 코드 가독성 향상
expirationSeconds
변수를 도입하여 코드의 가독성과 유지보수성을 높인 점이 좋습니다.
66-93
: 인증 코드 검증 테스트 케이스 추가유효한 인증 코드에 대한 테스트 케이스를 추가하여 정상 동작을 확인하신 점이 좋습니다. 토큰 검증까지 포함하여 로직의 완전성을 높였습니다.
95-114
: 만료된 인증 코드에 대한 예외 처리 테스트만료된 인증 코드 사용 시 올바른 예외가 발생하는지 테스트하여 예외 처리가 정확히 이루어짐을 검증하셨습니다.
116-135
: 유효하지 않은 인증 코드에 대한 예외 처리 테스트잘못된 인증 코드 입력 시 적절한 예외가 발생하는지 테스트하여 서비스의 안전성을 높이셨습니다.
application/src/main/kotlin/com/threedays/application/auth/service/AuthCodeService.kt
Show resolved
Hide resolved
domain/src/test/kotlin/com/threedays/domain/auth/entity/RegisterTokenTest.kt
Show resolved
Hide resolved
domain/src/test/kotlin/com/threedays/domain/auth/entity/RegisterTokenTest.kt
Show resolved
Hide resolved
domain/src/test/kotlin/com/threedays/domain/auth/entity/RegisterTokenTest.kt
Show resolved
Hide resolved
domain/src/main/kotlin/com/threedays/domain/auth/entity/RegisterToken.kt
Show resolved
Hide resolved
domain/src/main/kotlin/com/threedays/domain/auth/entity/RegisterToken.kt
Show resolved
Hide resolved
application/src/test/kotlin/com/threedays/application/auth/service/AuthCodeServiceTest.kt
Show resolved
Hide resolved
* 🩹 리뷰 반영 * 🩹 리뷰 반영 * ✨ 인증코드 검증 및 회원가입 토큰 발급 로직 작성
Summary by CodeRabbit
New Features
tokenSecret
속성 추가: 인증 구성 옵션이 확장되었습니다.Bug Fixes
NotFoundException
을 발생시키는 기능 추가: 오류 처리 개선.Tests