-
Notifications
You must be signed in to change notification settings - Fork 1
feat: 카카오 회원탈퇴 기능 구현 완료 #78
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
883b49b
[BOOK-180] refactor: apis - 회원 탈퇴 요청에서 WithdrawRequest DTO 제거 및 메서드 시…
move-hoon 103aefc
[BOOK-180] refactor: apis - WithdrawRequest DTO 제거로 인한 코드 정리
move-hoon 2e773c7
[BOOK-180] feat: apis - 카카오 OAuth 속성 추가 및 AuthConfig 수정
move-hoon 7c0eae6
[BOOK-180] feat: apis - WithdrawStrategyRequest DTO에 유효성 검사 어노테이션 추가
move-hoon 09d3f9c
[BOOK-180] feat: apis, infra - 카카오 회원 탈퇴 기능 구현 및 예외 처리 추가
move-hoon 145332d
[BOOK-180] feat: apis - 카카오 회원탈퇴 실패 및 응답 불일치에 대한 예외 코드 추가
move-hoon 7190e16
[BOOK-180] feat: apis - AppleWithdrawStrategy에서 WithdrawStrategyReque…
move-hoon e62fd9b
[BOOK-180] refactor: infra - 상수화 및 코드 정리, unlink 메서드의 요청 본문 구성 개선
move-hoon 5c3c589
[BOOK-180] fix: apis - 테스트용 카카오 admin-key 추가
move-hoon 7d1df73
[BOOK-180] refactor: apis - KakaoApiManager에서 adminKey를 KakaoOauthPro…
move-hoon 31e1f40
[BOOK-180] refactor: infra - withdraw 메서드의 requestBody 인자를 MultiValue…
move-hoon c30c41e
[BOOK-180] refactor: apis - KakaoApiManager의 unlink 메서드에서 응답 검증 로직을 별…
move-hoon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
apis/src/main/kotlin/org/yapp/apis/auth/dto/request/WithdrawRequest.kt
This file was deleted.
Oops, something went wrong.
11 changes: 8 additions & 3 deletions
11
apis/src/main/kotlin/org/yapp/apis/auth/dto/request/WithdrawStrategyRequest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
apis/src/main/kotlin/org/yapp/apis/auth/strategy/withdraw/AppleWithdrawStrategy.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 12 additions & 2 deletions
14
apis/src/main/kotlin/org/yapp/apis/auth/strategy/withdraw/KakaoWithdrawStrategy.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,27 @@ | ||
| package org.yapp.apis.auth.strategy.withdraw | ||
|
|
||
| import jakarta.validation.Valid | ||
| import mu.KotlinLogging | ||
| import org.springframework.stereotype.Component | ||
| import org.springframework.validation.annotation.Validated | ||
| import org.yapp.apis.auth.dto.request.WithdrawStrategyRequest | ||
| import org.yapp.apis.auth.manager.KakaoApiManager | ||
| import org.yapp.domain.user.ProviderType | ||
|
|
||
| @Component | ||
| @Validated | ||
| class KakaoWithdrawStrategy( | ||
| private val kakaoApiManager: KakaoApiManager | ||
| ) : WithdrawStrategy { | ||
| private val log = KotlinLogging.logger {} | ||
|
|
||
| override fun getProviderType() = ProviderType.KAKAO | ||
|
|
||
| override fun withdraw(request: WithdrawStrategyRequest) { | ||
| // kakaoApiManager.unlink(request.providerId) | ||
| override fun withdraw(@Valid request: WithdrawStrategyRequest) { | ||
| log.info("Starting Kakao withdrawal for user: ${request.userId}, providerId: ${request.providerId}") | ||
|
|
||
| val unlinkResponse = kakaoApiManager.unlink(request.providerId) | ||
|
|
||
| log.info("Successfully unlinked Kakao user. Response ID: ${unlinkResponse.id}") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
apis/src/main/kotlin/org/yapp/apis/config/KakaoOauthProperties.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package org.yapp.apis.config | ||
|
|
||
| import org.springframework.boot.context.properties.ConfigurationProperties | ||
|
|
||
| @ConfigurationProperties(prefix = "oauth.kakao") | ||
| data class KakaoOauthProperties( | ||
| val adminKey: String | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 28 additions & 2 deletions
30
infra/src/main/kotlin/org/yapp/infra/external/oauth/kakao/KakaoRestClient.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,49 @@ | ||
| package org.yapp.infra.external.oauth.kakao | ||
|
|
||
| import org.springframework.stereotype.Component | ||
| import org.springframework.util.LinkedMultiValueMap | ||
| import org.springframework.util.MultiValueMap | ||
| import org.springframework.web.client.RestClient | ||
| import org.yapp.infra.external.oauth.kakao.response.KakaoResponse | ||
| import org.yapp.infra.external.oauth.kakao.response.KakaoUnlinkResponse | ||
|
|
||
| @Component | ||
| class KakaoRestClient( | ||
| builder: RestClient.Builder | ||
| ) { | ||
| companion object { | ||
| private const val BASE_URL = "https://kapi.kakao.com" | ||
| private const val HEADER_AUTHORIZATION = "Authorization" | ||
| private const val AUTH_SCHEME_KAKAOAK = "KakaoAK" | ||
| private const val PARAM_TARGET_ID_TYPE = "target_id_type" | ||
| private const val PARAM_TARGET_ID = "target_id" | ||
| private const val VALUE_USER_ID = "user_id" | ||
| } | ||
|
|
||
| private val client = builder | ||
| .baseUrl("https://kapi.kakao.com") | ||
| .baseUrl(BASE_URL) | ||
| .build() | ||
|
|
||
| fun getUserInfo(bearerToken: String): KakaoResponse { | ||
| return client.get() | ||
| .uri("/v2/user/me") | ||
| .header("Authorization", bearerToken) | ||
| .header(HEADER_AUTHORIZATION, bearerToken) | ||
| .retrieve() | ||
| .body(KakaoResponse::class.java) | ||
| ?: throw IllegalStateException("Kakao API 응답이 null 입니다.") | ||
| } | ||
|
|
||
| fun unlink(adminKey: String, targetId: String): KakaoUnlinkResponse { | ||
| val requestBody: MultiValueMap<String, String> = LinkedMultiValueMap() | ||
| requestBody.add(PARAM_TARGET_ID_TYPE, VALUE_USER_ID) | ||
| requestBody.add(PARAM_TARGET_ID, targetId) | ||
|
|
||
| return client.post() | ||
| .uri("/v1/user/unlink") | ||
| .header(HEADER_AUTHORIZATION, "$AUTH_SCHEME_KAKAOAK $adminKey") | ||
| .body(requestBody) | ||
| .retrieve() | ||
| .body(KakaoUnlinkResponse::class.java) | ||
| ?: throw IllegalStateException("Kakao unlink API 응답이 null 입니다.") | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
infra/src/main/kotlin/org/yapp/infra/external/oauth/kakao/response/KakaoUnlinkResponse.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package org.yapp.infra.external.oauth.kakao.response | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty | ||
|
|
||
| data class KakaoUnlinkResponse private constructor( | ||
| @JsonProperty("id") | ||
| val id: String | ||
| ) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧹 Nitpick (assertive)
관리자 키에 대한 검증 추가를 고려해보세요.
설정 프로퍼티가 올바르게 구현되었지만,
adminKey는 중요한 정보이므로 빈 값이나 null 값에 대한 검증을 추가하는 것이 좋겠습니다.다음과 같이 검증 어노테이션을 추가할 수 있습니다:
📝 Committable suggestion
🤖 Prompt for AI Agents