-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
496 changed files
with
15,493 additions
and
3,900 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
name: Rolling Deployment | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
deploy-prod1: | ||
name: Deploy to Prod1 Instance | ||
runs-on: runner-prod1 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run Prod1 instance deploy script | ||
run: | | ||
cd ~/deploy && ./deploy.sh | ||
check-prod1: | ||
name: Check Prod1 Instance | ||
runs-on: runner-prod1 | ||
needs: deploy-prod1 | ||
|
||
steps: | ||
- name: Wait for Prod1 instance to be ready | ||
run: sleep 30 | ||
|
||
- name: Health check for Prod1 instance | ||
run: | | ||
RESPONSE=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:8080/health) | ||
if [ $RESPONSE -ne 200 ]; then | ||
echo "Prod1 instance deployment failed." | ||
exit 1 | ||
fi | ||
echo "Prod1 instance is healthy." | ||
deploy-prod2: | ||
name: Deploy to Prod2 Instance | ||
runs-on: runner-prod2 | ||
needs: check-prod1 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run Prod2 instance deploy script | ||
run: | | ||
cd ~/deploy && ./deploy.sh | ||
check-prod2: | ||
name: Check Prod2 Instance | ||
runs-on: runner-prod2 | ||
needs: deploy-prod2 | ||
|
||
steps: | ||
- name: Wait for Prod2 instance to be ready | ||
run: sleep 30 | ||
|
||
- name: Health check for Prod2 instance | ||
run: | | ||
RESPONSE=$(curl --write-out '%{http_code}' --silent --output /dev/null http://localhost:8080/health) | ||
if [ $RESPONSE -ne 200 ]; then | ||
echo "Prod2 instance deployment failed." | ||
exit 1 | ||
fi | ||
echo "Prod2 instance is healthy." |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
/frontend/.idea | ||
/backend/htmlReport | ||
*.pem | ||
backend/src/main/resources/auth/AuthKey.p8 |
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,4 +7,3 @@ build/ | |
out | ||
logs | ||
src/main/resources/firebase | ||
src/main/resources/application-prod.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
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
93 changes: 93 additions & 0 deletions
93
backend/src/main/java/mouda/backend/auth/Infrastructure/AppleOauthClient.java
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,93 @@ | ||
package mouda.backend.auth.Infrastructure; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.LinkedMultiValueMap; | ||
import org.springframework.util.MultiValueMap; | ||
import org.springframework.web.client.RestClient; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import mouda.backend.auth.Infrastructure.response.AppleRefreshTokenResponse; | ||
import mouda.backend.auth.implement.jwt.ClientSecretProvider; | ||
import mouda.backend.auth.presentation.response.OauthResponse; | ||
|
||
@Slf4j | ||
@Component | ||
@RequiredArgsConstructor | ||
public class AppleOauthClient implements OauthClient { | ||
|
||
public static final String CLIENT_ID = "site.mouda.backend"; | ||
private static final String APPLE_API_URL = "https://appleid.apple.com/auth"; | ||
private static final String GRANT_TYPE = "authorization_code"; | ||
|
||
private final RestClient restClient; | ||
private final ClientSecretProvider clientSecretProvider; | ||
|
||
@Value("${oauth.apple.redirect-uri}") | ||
private String redirectUri; | ||
|
||
@Override | ||
public String getIdToken(String code) { | ||
String tokenUrl = APPLE_API_URL + "/token"; | ||
MultiValueMap<String, String> formData = getFormData(code); | ||
|
||
OauthResponse oauthResponse = restClient.method(HttpMethod.POST) | ||
.uri(tokenUrl) | ||
.headers(httpHeaders -> httpHeaders.addAll(getHttpHeaders())) | ||
.body(formData) | ||
.retrieve() | ||
.body(OauthResponse.class); | ||
return oauthResponse.id_token(); | ||
} | ||
|
||
public String getRefreshToken(String code) { | ||
String tokenUrl = APPLE_API_URL + "/token"; | ||
MultiValueMap<String, String> formData = getFormData(code); | ||
|
||
AppleRefreshTokenResponse response = restClient.method(HttpMethod.POST) | ||
.uri(tokenUrl) | ||
.headers(httpHeaders -> httpHeaders.addAll(getHttpHeaders())) | ||
.body(formData) | ||
.retrieve() | ||
.body(AppleRefreshTokenResponse.class); | ||
return response.refresh_token(); | ||
} | ||
|
||
// TODO: 애플 심사 시 필요할 수 있으므로 제거하지 않습니다. | ||
// public void revoke(String refreshToken) { | ||
// String revokeUrl = APPLE_API_URL + "/oauth2/v2/revoke"; | ||
// MultiValueMap<String, String> formData = new LinkedMultiValueMap<>(); | ||
// formData.add("client_id", CLIENT_ID); | ||
// formData.add("client_secret", clientSecretProvider.provide()); | ||
// formData.add("token", refreshToken); | ||
// formData.add("token_hint_type", "refresh_token"); | ||
// | ||
// ResponseEntity<String> result = restClient.method(HttpMethod.POST) | ||
// .uri(revokeUrl) | ||
// .headers(httpHeaders -> httpHeaders.addAll(getHttpHeaders())) | ||
// .body(formData) | ||
// .retrieve() | ||
// .toEntity(String.class); | ||
// log.info("revoke status code : {}", result.getStatusCode()); | ||
// } | ||
|
||
private MultiValueMap<String, String> getFormData(String code) { | ||
MultiValueMap<String, String> formData = new LinkedMultiValueMap<>(); | ||
formData.add("client_id", CLIENT_ID); | ||
formData.add("client_secret", clientSecretProvider.provide()); | ||
formData.add("code", code); | ||
formData.add("grant_type", GRANT_TYPE); | ||
formData.add("redirect_uri", redirectUri); | ||
return formData; | ||
} | ||
|
||
private HttpHeaders getHttpHeaders() { | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
return headers; | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
backend/src/main/java/mouda/backend/auth/Infrastructure/GoogleOauthClient.java
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,74 @@ | ||
package mouda.backend.auth.Infrastructure; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.LinkedMultiValueMap; | ||
import org.springframework.util.MultiValueMap; | ||
import org.springframework.web.client.RestClient; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@Component | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class GoogleOauthClient implements OauthClient { | ||
|
||
private static final String CLIENT_ID = "630308965506-4eiek02jh2a5fbj7as1o84l4mks3s2tu.apps.googleusercontent.com"; | ||
private static final String GRANT_TYPE = "authorization_code"; | ||
private static final String GOOGLE_API_URL = "https://oauth2.googleapis.com/token"; | ||
|
||
@Value("${oauth.google.client-secret}") | ||
private String clientSecret; | ||
|
||
@Value("${oauth.google.redirect-uri}") | ||
private String redirectUri; | ||
|
||
private final RestClient restClient; | ||
|
||
@Override | ||
public String getIdToken(String code) { | ||
try { | ||
HttpHeaders headers = getHttpHeaders(); | ||
MultiValueMap<String, String> formData = getFormData(code); | ||
|
||
JsonNode oauthResponse = restClient.method(HttpMethod.POST) | ||
.uri(GOOGLE_API_URL) | ||
.headers(httpHeaders -> httpHeaders.addAll(headers)) | ||
.body(formData) | ||
.retrieve() | ||
.body(JsonNode.class); | ||
return oauthResponse.get("id_token").asText(); | ||
} catch (Exception e) { | ||
log.warn(e.getMessage()); | ||
// throw new AuthException(HttpStatus.BAD_GATEWAY, TOKEN_ISSUE_FAILED); | ||
throw e; | ||
} | ||
} | ||
|
||
private HttpHeaders getHttpHeaders() { | ||
HttpHeaders headers = new HttpHeaders(); | ||
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); | ||
return headers; | ||
} | ||
|
||
private MultiValueMap<String, String> getFormData(String code) { | ||
String scope = "https://www.googleapis.com/auth/userinfo.email " + | ||
"https://www.googleapis.com/auth/userinfo.profile " + | ||
"openid"; | ||
|
||
MultiValueMap<String, String> formData = new LinkedMultiValueMap<>(); | ||
formData.add("client_id", CLIENT_ID); | ||
formData.add("client_secret", clientSecret); | ||
formData.add("code", code); | ||
formData.add("grant_type", GRANT_TYPE); | ||
formData.add("redirect_uri", redirectUri); | ||
formData.add("scope", scope); | ||
return formData; | ||
} | ||
} |
Oops, something went wrong.