Skip to content

Commit 66d9fc7

Browse files
authored
Revert "[YS-456] feat: OAuth 로그인 API의 redirect URI 동적 처리 (#140)"
This reverts commit 93b1cce.
1 parent 93b1cce commit 66d9fc7

File tree

13 files changed

+30
-115
lines changed

13 files changed

+30
-115
lines changed

application/src/main/kotlin/com/dobby/auth/GoogleRedirectUriProperties.kt

Lines changed: 0 additions & 10 deletions
This file was deleted.

application/src/main/kotlin/com/dobby/auth/RedirectUriValidator.kt

Lines changed: 0 additions & 10 deletions
This file was deleted.

application/src/main/kotlin/com/dobby/service/AuthService.kt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.dobby.service
22

3-
import com.dobby.auth.RedirectUriValidator
4-
import com.dobby.exception.InvalidRedirectUriException
53
import com.dobby.usecase.auth.FetchGoogleUserInfoUseCase
64
import com.dobby.usecase.auth.FetchNaverUserInfoUseCase
75
import com.dobby.usecase.auth.GenerateTestTokenUseCase
@@ -14,20 +12,12 @@ class AuthService(
1412
private val fetchGoogleUserInfoUseCase: FetchGoogleUserInfoUseCase,
1513
private val fetchNaverUserInfoUseCase: FetchNaverUserInfoUseCase,
1614
private val generateTokenWithRefreshTokenUseCase: GenerateTokenWithRefreshTokenUseCase,
17-
private val generateTestTokenUseCase: GenerateTestTokenUseCase,
18-
private val redirectUriValidator: RedirectUriValidator
15+
private val generateTestTokenUseCase: GenerateTestTokenUseCase
1916
) {
2017
fun getGoogleUserInfo(input: FetchGoogleUserInfoUseCase.Input): FetchGoogleUserInfoUseCase.Output {
21-
validateGoogleRedirectUri(input.redirectUri)
2218
return fetchGoogleUserInfoUseCase.execute(input)
2319
}
2420

25-
private fun validateGoogleRedirectUri(uri: String) {
26-
if (!redirectUriValidator.isValidGoogleRedirectUri(uri)) {
27-
throw InvalidRedirectUriException
28-
}
29-
}
30-
3121
fun getNaverUserInfo(input: FetchNaverUserInfoUseCase.Input): FetchNaverUserInfoUseCase.Output {
3222
return fetchNaverUserInfoUseCase.execute(input)
3323
}

application/src/main/kotlin/com/dobby/usecase/auth/FetchGoogleUserInfoUseCase.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ class FetchGoogleUserInfoUseCase(
1717

1818
data class Input(
1919
val authorizationCode: String,
20-
val role: RoleType,
21-
val redirectUri: String
20+
val role: RoleType
2221
)
2322

2423
data class Output(
@@ -34,7 +33,7 @@ class FetchGoogleUserInfoUseCase(
3433
)
3534

3635
override fun execute(input: Input): Output {
37-
val oauthToken = googleAuthGateway.getAccessToken(input.authorizationCode, input.redirectUri).accessToken
36+
val oauthToken = googleAuthGateway.getAccessToken(input.authorizationCode).accessToken
3837
val userInfo = googleAuthGateway.getUserInfo(oauthToken)
3938
val email = userInfo.email
4039
val member = email.let { memberGateway.findByOauthEmailAndStatus(email, MemberStatus.ACTIVE) }

application/src/test/kotlin/com/dobby/usecase/auth/FetchGoogleUserInfoUseCaseTest.kt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ class FetchGoogleUserInfoUseCaseTest : BehaviorSpec({
2828
)
2929

3030
given("Google OAuth 요청이 들어왔을 때") {
31-
val input = FetchGoogleUserInfoUseCase.Input(
32-
authorizationCode = "valid-auth-code",
33-
role = RoleType.PARTICIPANT,
34-
redirectUri = "http://localhost:8080/auth/google/callback"
35-
)
31+
val input = FetchGoogleUserInfoUseCase.Input(authorizationCode = "valid-auth-code", role = RoleType.PARTICIPANT)
3632
val mockMember = Member(
3733
id = "1",
3834
oauthEmail = "test@example.com",
@@ -48,7 +44,7 @@ class FetchGoogleUserInfoUseCaseTest : BehaviorSpec({
4844

4945
val mockEmptyMember = null
5046
val mockGoogleTokenResponse = GoogleToken("mock-access-token")
51-
every { googleAuthGateway.getAccessToken(any(), any()) } returns mockGoogleTokenResponse
47+
every { googleAuthGateway.getAccessToken(any()) } returns mockGoogleTokenResponse
5248
every { googleAuthGateway.getUserInfo("mock-access-token") } returns mockk {
5349
every { email } returns "test@example.com"
5450
}
@@ -72,12 +68,7 @@ class FetchGoogleUserInfoUseCaseTest : BehaviorSpec({
7268
}
7369

7470
// 테스트 2: 등록된 멤버가 없는 경우
75-
every {
76-
memberGateway.findByOauthEmailAndStatus(
77-
"test@example.com",
78-
MemberStatus.ACTIVE
79-
)
80-
} returns mockEmptyMember
71+
every { memberGateway.findByOauthEmailAndStatus("test@example.com", MemberStatus.ACTIVE) } returns mockEmptyMember
8172

8273
`when`("등록되지 않은 유저가 있는 경우") {
8374
val result: FetchGoogleUserInfoUseCase.Output = fetchGoogleUserInfoUseCase.execute(input)

domain/src/main/kotlin/com/dobby/exception/DobbyException.kt

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@ package com.dobby.exception
33
/**
44
* Top-level exception class for Dobby application
55
*/
6-
sealed class DobbyException(val code: String, message: String, cause: Throwable? = null) :
7-
RuntimeException(message, cause)
6+
sealed class DobbyException(val code: String, message: String, cause: Throwable? = null) : RuntimeException(message, cause)
87

98
/**
109
* ClientException: Exceptions caused by invalid client requests
1110
* - Authentication and authorization failures
1211
* - Invalid or missing request data
1312
*/
14-
sealed class ClientException(code: String, message: String, cause: Throwable? = null) :
15-
DobbyException(code, message, cause)
13+
sealed class ClientException(code: String, message: String, cause: Throwable? = null) : DobbyException(code, message, cause)
1614

1715
/**
1816
* Common error codes
@@ -29,7 +27,6 @@ data object AuthenticationTokenNotValidException : ClientException("AU0002", "Au
2927
data object AuthenticationTokenExpiredException : ClientException("AU0003", "Authentication token has expired.")
3028
data object InvalidTokenTypeException : ClientException("AU0004", "Invalid token type")
3129
data object InvalidTokenValueException : ClientException("AU0005", "Invalid token value")
32-
data object InvalidRedirectUriException : ClientException("AU0006", "Invalid redirect URI")
3330

3431
/**
3532
* Email Verification error codes
@@ -41,47 +38,31 @@ data object CodeNotCorrectException : ClientException("VE0004", "Verification co
4138
data object CodeExpiredException : ClientException("VE0005", "Verification code is expired")
4239
data object EmailFormatInvalidException : ClientException("VE0006", "Email is invalid format")
4340
data object EmailAlreadyVerifiedException : ClientException("VE0007", "This email is already verified.")
44-
data object TooManyVerificationRequestException :
45-
ClientException("VE0008", "You can request verification up to 3 in one day.")
41+
data object TooManyVerificationRequestException : ClientException("VE0008", "You can request verification up to 3 in one day.")
4642

4743
/**
4844
* Member error codes
4945
*/
5046
data object MemberNotFoundException : ClientException("ME0001", "Member not found")
51-
data class MemberRoleMismatchException(val role: String) :
52-
ClientException("ME0002", "Already registered as another role: $role")
53-
47+
data class MemberRoleMismatchException(val role: String) : ClientException("ME0002", "Already registered as another role: $role")
5448
data object ResearcherNotFoundException : ClientException("ME0003", "Researcher Not Found.")
5549
data object ParticipantNotFoundException : ClientException("ME0004", "Participant Not Found.")
5650
data object EmailNotValidateException : ClientException("ME0005", "You should validate your school email first")
57-
data object SignupOauthEmailDuplicateException :
58-
ClientException("ME0006", "You've already joined with requested OAuth email")
59-
51+
data object SignupOauthEmailDuplicateException : ClientException("ME0006", "You've already joined with requested OAuth email")
6052
data object ContactEmailDuplicateException : ClientException("ME0007", "This contact email is already in use.")
6153
data object MemberConsentNotFoundException : ClientException("ME0008", "Member Consent Not Found.")
62-
data object SignupUnivEmailDuplicateException :
63-
ClientException("ME0009", "You've already joined with requested university email")
54+
data object SignupUnivEmailDuplicateException : ClientException("ME0009", "You've already joined with requested university email")
6455

6556
/**
6657
* Experiment error codes
6758
*/
6859
data object ExperimentPostNotFoundException : ClientException("EP0001", "Experiment Post Not Found.")
69-
data object ExperimentAreaOverflowException :
70-
ClientException("EP0003", "You can only select up to 5 Area options in 1 Region.")
71-
72-
data object ExperimentAreaInCorrectException :
73-
ClientException("EP0004", "Selected Area doesn't belong to correct Region.")
74-
60+
data object ExperimentAreaOverflowException : ClientException("EP0003", "You can only select up to 5 Area options in 1 Region.")
61+
data object ExperimentAreaInCorrectException : ClientException("EP0004", "Selected Area doesn't belong to correct Region.")
7562
data object ExperimentPostImageSizeException : ClientException("EP0005", "Image can be uploaded maximum 3 images.")
76-
data object ExperimentPostRecruitStatusException :
77-
ClientException("EP0006", "You cannot update recruitStatus with closed recruitment post.")
78-
79-
data object ExperimentPostUpdateDateException :
80-
ClientException("EP0007", "You cannot update startDate, endDate with closed recruitment post.")
81-
82-
data object ExperimentPostInvalidOnlineRequestException :
83-
ClientException("EP0008", "place, region, area field value must be null when MatchType is online.")
84-
63+
data object ExperimentPostRecruitStatusException : ClientException("EP0006", "You cannot update recruitStatus with closed recruitment post.")
64+
data object ExperimentPostUpdateDateException : ClientException("EP0007", "You cannot update startDate, endDate with closed recruitment post.")
65+
data object ExperimentPostInvalidOnlineRequestException : ClientException("EP0008", "place, region, area field value must be null when MatchType is online.")
8566
data object ExperimentPostTitleException : ClientException("EP0009", "Title cannot be null.")
8667
data object ExperimentPostRewardException : ClientException("EP0010", "Reward cannot be null.")
8768
data object ExperimentPostContentException : ClientException("EP0011", "Content cannot be null.")
@@ -93,7 +74,6 @@ data object ExperimentPostLeadResearcherException : ClientException("EP0013", "L
9374
* - Database or infrastructure failures
9475
* - Unexpected backend processing issues
9576
*/
96-
sealed class ServerException(code: String, message: String, cause: Throwable? = null) :
97-
DobbyException(code, message, cause)
77+
sealed class ServerException(code: String, message: String, cause: Throwable? = null) : DobbyException(code, message, cause)
9878

9979
data object UnknownServerErrorException : ServerException("DB0001", "An unknown error has occurred")

domain/src/main/kotlin/com/dobby/gateway/auth/GoogleAuthGateway.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ import com.dobby.model.auth.GoogleToken
44
import com.dobby.model.auth.GoogleUserInfo
55

66
interface GoogleAuthGateway {
7-
8-
fun getAccessToken(
9-
code: String,
10-
redirectUri: String
11-
): GoogleToken
12-
7+
fun getAccessToken(code: String): GoogleToken
138
fun getUserInfo(accessToken: String): GoogleUserInfo
149
}

infrastructure/src/main/kotlin/com/dobby/external/gateway/auth/GoogleAuthGatewayImpl.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ class GoogleAuthGatewayImpl(
1515
private val googleUserInfoFeignClient: GoogleUserInfoFeginClient
1616
) : GoogleAuthGateway {
1717

18-
override fun getAccessToken(
19-
code: String,
20-
redirectUri: String
21-
): GoogleToken = googleAuthFeignClient.getAccessToken(
22-
clientId = googleAuthProperties.clientId,
23-
redirectUri = redirectUri,
24-
code = code,
25-
clientSecret = googleAuthProperties.clientSecret,
26-
grantType = googleAuthProperties.grantType
27-
).toDomain()
18+
override fun getAccessToken(code: String): GoogleToken {
19+
return googleAuthFeignClient.getAccessToken(
20+
clientId = googleAuthProperties.clientId,
21+
redirectUri = googleAuthProperties.redirectUri,
22+
code = code,
23+
clientSecret = googleAuthProperties.clientSecret,
24+
grantType = googleAuthProperties.grantType
25+
).toDomain()
26+
}
2827

2928
override fun getUserInfo(accessToken: String): GoogleUserInfo {
3029
return googleUserInfoFeignClient.getUserInfo("Bearer $accessToken")

infrastructure/src/main/resources/application.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,3 @@ cors:
8787

8888
swagger:
8989
server-url: http://localhost:8080
90-
91-
oauth:
92-
google:
93-
redirectUris:
94-
- "http://localhost:8080/oauth2/callback/google"

infrastructure/src/main/resources/template-application-local.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,3 @@ cors:
9090

9191
swagger:
9292
server-url: http://localhost:8080
93-
94-
oauth:
95-
google:
96-
redirectUris:
97-
- "http://localhost:8080/oauth2/callback/google"

0 commit comments

Comments
 (0)