Repository navigation
[chore] 앱인토스 mTLS 인증서 및 미니앱 CORS 설정 #76
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 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1d78076
chore: 앱인토스 API 호출용 mTLS 인증서 설정 추가
kyer5 971f58f
chore: 앱인토스 미니앱 Origin CORS 허용 추가
kyer5 88583f2
chore: 앱인토스 API 클라이언트에 연결/응답 타임아웃 설정 추가
kyer5 bb962af
test: 앱인토스 API 클라이언트 타임아웃 설정 테스트 추가
kyer5 ecce5f4
[feature] 앱인토스 API 공통 응답 처리 클라이언트 추가 (#77)
kyer5 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # 운영 서버 전용 설정. cd-prod가 .env의 COMPOSE_FILE로 docker-compose.yml과 함께 적용한다. | ||
| services: | ||
| app: | ||
| environment: | ||
| TOSS_MTLS_CERT_PATH: ${TOSS_MTLS_CERT_PATH:?} | ||
| TOSS_MTLS_KEY_PATH: ${TOSS_MTLS_KEY_PATH:?} | ||
| volumes: | ||
| # 앱인토스 mTLS 인증서는 저장소에 두지 않고 운영 서버 호스트에만 보관한다. | ||
| - ${TOSS_MTLS_HOST_DIR:?}:/secrets/toss:ro |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/nexters/gotggam/global/config/TossApiClientConfig.java
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,31 @@ | ||
| package com.nexters.gotggam.global.config; | ||
|
|
||
| import java.net.http.HttpClient; | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
| import org.springframework.boot.ssl.SslBundle; | ||
| import org.springframework.boot.ssl.SslBundles; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.http.client.JdkClientHttpRequestFactory; | ||
| import org.springframework.web.client.RestClient; | ||
|
|
||
| // 앱인토스 API는 mTLS로 호출 주체를 식별하므로, 발급받은 클라이언트 인증서를 TLS 핸드셰이크에 실어 보낸다. | ||
| @Configuration | ||
| @EnableConfigurationProperties(TossApiProperties.class) | ||
| @ConditionalOnProperty(prefix = "toss.api", name = "enabled", havingValue = "true") | ||
| public class TossApiClientConfig { | ||
|
|
||
| @Bean | ||
| public RestClient tossApiRestClient(TossApiProperties properties, SslBundles sslBundles) { | ||
| SslBundle sslBundle = sslBundles.getBundle(properties.sslBundle()); | ||
| HttpClient httpClient = HttpClient.newBuilder() | ||
| .sslContext(sslBundle.createSslContext()) | ||
| .build(); | ||
|
|
||
| return RestClient.builder() | ||
| .baseUrl(properties.baseUrl()) | ||
| .requestFactory(new JdkClientHttpRequestFactory(httpClient)) | ||
| .build(); | ||
| } | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/nexters/gotggam/global/config/TossApiProperties.java
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,20 @@ | ||
| package com.nexters.gotggam.global.config; | ||
|
|
||
| import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
|
||
| @ConfigurationProperties(prefix = "toss.api") | ||
| public record TossApiProperties( | ||
| boolean enabled, | ||
| String baseUrl, | ||
| String sslBundle | ||
| ) { | ||
|
|
||
| public TossApiProperties { | ||
| if (baseUrl == null || baseUrl.isBlank()) { | ||
| baseUrl = "https://apps-in-toss-api.toss.im"; | ||
| } | ||
| if (sslBundle == null || sslBundle.isBlank()) { | ||
| sslBundle = "toss"; | ||
| } | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.