-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from TeamTroublePainter/feature/DRAW-390
DRAW-390 구글 로그인
- Loading branch information
Showing
14 changed files
with
78 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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 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
adapter/oauth/src/main/kotlin/com/xorker/draw/oauth/google/GoogleApiConfiguration.kt
This file contains 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 com.xorker.draw.oauth.google | ||
|
||
import org.springframework.boot.context.properties.EnableConfigurationProperties | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
@EnableConfigurationProperties(GoogleApiProperties::class) | ||
class GoogleApiConfiguration |
8 changes: 8 additions & 0 deletions
8
adapter/oauth/src/main/kotlin/com/xorker/draw/oauth/google/GoogleApiProperties.kt
This file contains 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 com.xorker.draw.oauth.google | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties | ||
|
||
@ConfigurationProperties("oauth.google") | ||
data class GoogleApiProperties( | ||
val clientId: String, | ||
) |
27 changes: 27 additions & 0 deletions
27
adapter/oauth/src/main/kotlin/com/xorker/draw/oauth/google/GoogleAuthService.kt
This file contains 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,27 @@ | ||
package com.xorker.draw.oauth.google | ||
|
||
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier | ||
import com.google.api.client.http.javanet.NetHttpTransport | ||
import com.google.api.client.json.gson.GsonFactory | ||
import com.xorker.draw.exception.OAuthFailureException | ||
import java.security.GeneralSecurityException | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
internal class GoogleAuthService( | ||
googleApiProperties: GoogleApiProperties, | ||
) { | ||
private val idTokenVerifier = | ||
GoogleIdTokenVerifier.Builder(NetHttpTransport(), GsonFactory.getDefaultInstance()) | ||
.setAudience(listOf(googleApiProperties.clientId)) | ||
.build() | ||
|
||
fun getPlatformUserId(token: String): String { | ||
try { | ||
val idToken = idTokenVerifier.verify(token) | ||
return idToken?.payload?.subject ?: throw OAuthFailureException | ||
} catch (e: GeneralSecurityException) { | ||
throw OAuthFailureException | ||
} | ||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -2,3 +2,5 @@ oauth: | |
apple: | ||
iss: https://appleid.apple.com | ||
client-id: ${APPLE_CLIENT_ID} | ||
google: | ||
client-id: ${GOOGLE_CLIENT_ID} |
This file contains 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 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 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 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: 8 additions & 6 deletions
14
domain/src/main/kotlin/com/xorker/draw/auth/AuthPlatform.kt
This file contains 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,6 +1,8 @@ | ||
package com.xorker.draw.auth | ||
|
||
enum class AuthPlatform(description: String) { | ||
APPLE("애플"), | ||
; | ||
} | ||
package com.xorker.draw.auth | ||
|
||
enum class AuthPlatform(description: String) { | ||
APPLE("애플"), | ||
GOOGLE("구글"), | ||
|
||
; | ||
} |
This file contains 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 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 |
---|---|---|
|
@@ -7,3 +7,8 @@ data class User( | |
val id: UserId, | ||
val name: String, | ||
) | ||
|
||
data class UserInfo( | ||
val id: UserId, | ||
val name: String?, | ||
) |
This file contains 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