-
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 #135 from grida-diary/main
docs
- Loading branch information
Showing
71 changed files
with
430 additions
and
186 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
19 changes: 19 additions & 0 deletions
19
grida-clients/kakao-client/src/main/resources/application-kakao-client.yml
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,19 @@ | ||
--- | ||
spring: | ||
config: | ||
activate: | ||
on-profile: dev | ||
kakao: | ||
appKey: ${KAKAO_APP_KEY} | ||
base-uri: http://localhost:8080 | ||
api-path: ${KAKAO_REDIRECT_URL} | ||
|
||
--- | ||
spring: | ||
config: | ||
activate: | ||
on-profile: prod | ||
kakao: | ||
appKey: ${KAKAO_APP_KEY} | ||
base-uri: https://grida.today | ||
api-path: ${KAKAO_REDIRECT_URL} |
14 changes: 14 additions & 0 deletions
14
grida-clients/openai-client/src/main/resources/application-openai-client.yml
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,14 @@ | ||
openai: | ||
secret-key: ${OPEN_AI_SECRET_KEY} | ||
|
||
--- | ||
spring: | ||
config: | ||
activate: | ||
on-profile: dev | ||
|
||
--- | ||
spring: | ||
config: | ||
activate: | ||
on-profile: prod |
2 changes: 0 additions & 2 deletions
2
grida-clients/openai-client/src/main/resources/application.yml
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
grida-clients/s3-client/src/main/resources/application-s3-client.yml
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,18 @@ | ||
storage: | ||
aws: | ||
access-key: ${S3_ACCESS_KEY} | ||
secret-key: ${S3_SECRET_KEY} | ||
region: ${S3_REGION} | ||
bucket: ${S3_BUCKET} | ||
host: ${CDN_HOST} | ||
--- | ||
spring: | ||
config: | ||
activate: | ||
on-profile: dev | ||
|
||
--- | ||
spring: | ||
config: | ||
activate: | ||
on-profile: prod |
7 changes: 0 additions & 7 deletions
7
grida-clients/storage-client/src/main/resources/application-storage-client.yml
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
grida-common/src/main/kotlin/org/grida/api/dto/ListResponse.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,19 @@ | ||
package org.grida.api.dto | ||
|
||
data class ListResponse<T>( | ||
val count: Int, | ||
val list: List<T> | ||
) { | ||
|
||
companion object { | ||
fun <T> from( | ||
list: List<T>, | ||
mapAction: () -> T | ||
): ListResponse<T> { | ||
return ListResponse( | ||
list.size, | ||
list.map { mapAction.invoke() } | ||
) | ||
} | ||
} | ||
} |
File renamed without changes.
Empty file.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
### Health Checking Api | ||
GET {{core-api}}/api/health |
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 @@ | ||
{ | ||
"local": { | ||
"core-api": "http://localhost:8080" | ||
}, | ||
"prod": { | ||
"core-api": "https://grida.today" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
grida-core/core-api/src/main/kotlin/org/grida/auth/AuthProcessor.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,5 @@ | ||
package org.grida.auth | ||
|
||
interface AuthProcessor { | ||
fun process(code: String): AuthToken | ||
} |
16 changes: 16 additions & 0 deletions
16
grida-core/core-api/src/main/kotlin/org/grida/auth/AuthProcessorSelector.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,16 @@ | ||
package org.grida.auth | ||
|
||
import org.grida.error.GridaException | ||
import org.grida.error.NotSupportedLoginPlatform | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class AuthProcessorSelector( | ||
private val authProcessors: Map<String, AuthProcessor> | ||
) { | ||
|
||
fun select(platform: String): AuthProcessor { | ||
return authProcessors["${platform}AuthProcessor"] | ||
?: throw GridaException(NotSupportedLoginPlatform) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
grida-core/core-api/src/main/kotlin/org/grida/auth/AuthToken.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,6 @@ | ||
package org.grida.auth | ||
|
||
data class AuthToken( | ||
val accessToken: String, | ||
val refreshToken: String | ||
) |
22 changes: 22 additions & 0 deletions
22
grida-core/core-api/src/main/kotlin/org/grida/auth/AuthTokenProvider.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,22 @@ | ||
package org.grida.auth | ||
|
||
import io.wwan13.wintersecurity.jwt.TokenGenerator | ||
import org.grida.config.TokenPayload | ||
import org.grida.domain.user.User | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class AuthTokenProvider( | ||
private val tokenGenerator: TokenGenerator | ||
) { | ||
|
||
fun provide( | ||
user: User | ||
): AuthToken { | ||
val tokenPayload = TokenPayload(user.id, user.role) | ||
return AuthToken( | ||
accessToken = tokenGenerator.accessToken(tokenPayload), | ||
refreshToken = tokenGenerator.refreshToken(tokenPayload) | ||
) | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
grida-core/core-api/src/main/kotlin/org/grida/auth/InternalAuthProcessor.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,36 @@ | ||
package org.grida.auth | ||
|
||
import org.grida.domain.user.LoginOption | ||
import org.grida.domain.user.LoginPlatform | ||
import org.grida.domain.user.UserService | ||
import org.grida.error.GridaException | ||
import org.grida.error.NotSupportedLoginPlatform | ||
import org.springframework.beans.factory.annotation.Value | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class InternalAuthProcessor( | ||
@Value("\${spring.profiles.active}") | ||
private val activeProfile: String, | ||
private val userService: UserService, | ||
private val authTokenProvider: AuthTokenProvider | ||
) : AuthProcessor { | ||
|
||
override fun process(code: String): AuthToken { | ||
validateActiveProfile() | ||
val loginOption = LoginOption(LoginPlatform.ADMIN, code) | ||
val user = userService.read(loginOption.identifier.toLong()) | ||
|
||
return authTokenProvider.provide(user) | ||
} | ||
|
||
private fun validateActiveProfile() { | ||
if (!enableProfiles.contains(activeProfile)) { | ||
throw throw GridaException(NotSupportedLoginPlatform) | ||
} | ||
} | ||
|
||
companion object { | ||
val enableProfiles = listOf("dev", "stag") | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
grida-core/core-api/src/main/kotlin/org/grida/auth/KakaoAuthProcessor.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,26 @@ | ||
package org.grida.auth | ||
|
||
import org.grida.domain.user.LoginOption | ||
import org.grida.domain.user.LoginPlatform | ||
import org.grida.domain.user.UserService | ||
import org.grida.user.KakaoUserClient | ||
import org.springframework.stereotype.Component | ||
|
||
@Component | ||
class KakaoAuthProcessor( | ||
private val kakaoAuthClient: KakaoAuthClient, | ||
private val kakaoUserClient: KakaoUserClient, | ||
private val userService: UserService, | ||
private val authTokenProvider: AuthTokenProvider | ||
) : AuthProcessor { | ||
|
||
override fun process(code: String): AuthToken { | ||
val kakaoToken = kakaoAuthClient.provideAuthToken(code) | ||
val kakaoProfile = kakaoUserClient.readUserProfile(kakaoToken.accessToken) | ||
val loginOption = LoginOption(LoginPlatform.KAKAO, kakaoProfile.id) | ||
|
||
val user = userService.readUserByLoginOption(loginOption) | ||
?: userService.appendAndReturnNormalUser(kakaoProfile.name, loginOption) | ||
return authTokenProvider.provide(user) | ||
} | ||
} |
21 changes: 1 addition & 20 deletions
21
grida-core/core-api/src/main/kotlin/org/grida/config/CoreApiConfig.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,27 +1,8 @@ | ||
package org.grida.config | ||
|
||
import io.wwan13.springrequestlogger.configure.EnableLoggingRequest | ||
import io.wwan13.springrequestlogger.configure.LogMessageConfigurer | ||
import io.wwan13.springrequestlogger.context.RequestContext | ||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan | ||
import org.springframework.context.annotation.Configuration | ||
import java.util.function.Function | ||
|
||
@Configuration | ||
@ConfigurationPropertiesScan | ||
@EnableLoggingRequest | ||
class CoreApiConfig : LogMessageConfigurer { | ||
|
||
override fun format(): Function<RequestContext, String> { | ||
return Function { context -> | ||
""" | ||
| | ||
| ${context.method} '${context.uri}' - ${context.status} (${context.elapsed} s) | ||
| >> Request Headers : ${context.requestHeaders} | ||
| >> Request Params : ${context.requestParams} | ||
| >> Request Body : ${context.requestBody} | ||
| >> Response Body : ${context.responseBody} | ||
""".trimMargin() | ||
} | ||
} | ||
} | ||
class CoreApiConfig |
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: 14 additions & 0 deletions
14
grida-core/core-api/src/main/kotlin/org/grida/config/RequestLoggingConfig.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,14 @@ | ||
package org.grida.config | ||
|
||
import io.wwan13.springrequestlogger.configure.EnableLoggingRequest | ||
import io.wwan13.springrequestlogger.configure.LogMessageConfigurer | ||
import org.springframework.context.annotation.Configuration | ||
|
||
@Configuration | ||
@EnableLoggingRequest | ||
class RequestLoggingConfig : LogMessageConfigurer { | ||
|
||
override fun excludePathPatterns(): List<String> { | ||
return listOf("/api/actuator/**") | ||
} | ||
} |
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
Oops, something went wrong.