diff --git a/.github/workflows/dev-build-and-deploy.yaml b/.github/workflows/dev-build-and-deploy.yaml index cd5928b0..f3084374 100644 --- a/.github/workflows/dev-build-and-deploy.yaml +++ b/.github/workflows/dev-build-and-deploy.yaml @@ -24,6 +24,13 @@ jobs: java-version: "17" distribution: "corretto" + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_S3_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.AWS_S3_SECRET_KEY }} + aws-region: ap-northeast-2 + - name: Cache Gradle uses: actions/cache@v3 with: @@ -111,36 +118,10 @@ jobs: -p 9292:9292 \ -p 3100:3100 \ -e SPRING_PROFILES_ACTIVE=dev \ - -e SPRING_SERVLET_MULTIPART_MAX-FILE-SIZE=30MB \ - -e SPRING_SERVLET_MULTIPART_MAX-REQUEST-SIZE=30MB \ - -e AWS_REDIS_HOST=${{ secrets.DEV_REDIS_HOST }} \ - -e AWS_REDIS_PORT=${{ secrets.DEV_REDIS_PORT }} \ - -e SPRING_DATASOURCE_URL=${{ secrets.DEV_DB_URL }} \ - -e SPRING_DATASOURCE_USERNAME=${{ secrets.DEV_DB_USERNAME }} \ - -e SPRING_DATASOURCE_PASSWORD=${{ secrets.DEV_DB_PASSWORD }} \ - -e SPRING_JWT_SECRET=${{ secrets.JWT_SECRET }} \ - -e OAUTH_CLIENTID=${{ secrets.KAKAO_CLIENT_ID }} \ - -e OAUTH_KAUTHTOKENURLHOST=${{ secrets.KAUTH_TOKEN_URL_HOST }} \ - -e OAUTH_KAUTHUSERURLHOST=${{ secrets.KAUTH_USER_URL_HOST }} \ - -e OAUTH_KAKAOCLIENTID=${{ secrets.OAUTH_KAKAOCLIENTID }} \ - -e OAUTH_KAKAOAUTHTOKENURLHOST=${{ secrets.KAKAOAUTHTOKENURLHOST }} \ - -e OAUTH_KAKAOAUTHUSERURLHOST=${{ secrets.KAKAOAUTHUSERURLHOST }} \ - -e OAUTH_KAKAOREDIRECTURL=${{ secrets.KAKAOREDIRECTURL }} \ - -e OAUTH_GOOGLECLIENTID=${{ secrets.GOOGLECLIENTID }} \ - -e OAUTH_GOOGLECLIENTSECRET=${{ secrets.GOOGLECLIENTSECRET }} \ - -e OAUTH_GOOGLEREDIRECTURL=${{ secrets.GOOGLEREDIRECTURL }} \ - -e OAUTH_GOOGLEAUTHTOKENURLHOST=${{ secrets.GOOGLEAUTHTOKENURLHOST }} \ - -e OAUTH_GOOGLEUSERURLHOST=${{ secrets.GOOGLEUSERURLHOST }} \ -e SPRING_JPA_HIBERNATE_DDL_AUTO=validate \ - -e AWS_S3_ACCESS_KEY=${{ secrets.AWS_S3_ACCESS_KEY }} \ - -e AWS_S3_SECRET_KEY=${{ secrets.AWS_S3_SECRET_KEY }} \ - -e AWS_S3_BUCKET_NAME=${{ secrets.DEV_AWS_S3_BUCKET_NAME }} \ - -e AWS_S3_BASICPROFILEIMAGEURL=${{ secrets.BASICPROFILEIMAGEURL }} \ + -e SPRING_CREDENTIALS_ACCESS_KEY=${{secrets.AWS_S3_ACCESS_KEY}} \ + -e SPRING_CREDENTIALS_SECRET_KEY=${{secrets.AWS_S3_SECRET_KEY}} \ -e TZ=Asia/Seoul \ - -e SENTRY_DSN=${{ secrets.SENTRY_DSN }} \ - -e SENTRY_ENABLE_TRACING=true \ - -e SENTRY_ENVIRONMENT=prod \ - -e LOKI_URL=${{ secrets.LOKI_SERVER_URL }} \ ${{ secrets.DOCKERHUB_USERNAME }}/spot-server:dev-${{ github.sha }} docker system prune -af diff --git a/.github/workflows/manual-prod-deploy.yaml b/.github/workflows/manual-prod-deploy.yaml index e56e7ce2..cf99069d 100644 --- a/.github/workflows/manual-prod-deploy.yaml +++ b/.github/workflows/manual-prod-deploy.yaml @@ -48,35 +48,9 @@ jobs: -p 9292:9292 \ -p 3100:3100 \ -e SPRING_PROFILES_ACTIVE=prod \ - -e SPRING_SERVLET_MULTIPART_MAX-FILE-SIZE=30MB \ - -e SPRING_SERVLET_MULTIPART_MAX-REQUEST-SIZE=30MB \ - -e AWS_REDIS_HOST=${{ secrets.PROD_REDIS_HOST }} \ - -e AWS_REDIS_PORT=${{ secrets.PROD_REDIS_PORT }} \ - -e SPRING_DATASOURCE_URL=${{ secrets.PROD_DB_URL }} \ - -e SPRING_DATASOURCE_USERNAME=${{ secrets.PROD_DB_USERNAME }} \ - -e SPRING_DATASOURCE_PASSWORD=${{ secrets.PROD_DB_PASSWORD }} \ - -e SPRING_JWT_SECRET=${{ secrets.JWT_SECRET }} \ - -e KAKAO_CLIENT_ID=${{ secrets.KAKAO_CLIENT_ID }} \ - -e OAUTH_KAUTHTOKENURLHOST=${{ secrets.KAUTH_TOKEN_URL_HOST }} \ - -e OAUTH_KAUTHUSERURLHOST=${{ secrets.KAUTH_USER_URL_HOST }} \ - -e OAUTH_KAKAOCLIENTID=${{ secrets.OAUTH_KAKAOCLIENTID }} \ - -e OAUTH_KAKAOAUTHTOKENURLHOST=${{ secrets.KAKAOAUTHTOKENURLHOST }} \ - -e OAUTH_KAKAOAUTHUSERURLHOST=${{ secrets.KAKAOAUTHUSERURLHOST }} \ - -e OAUTH_KAKAOREDIRECTURL=${{ secrets.KAKAOREDIRECTURL }} \ - -e OAUTH_GOOGLECLIENTID=${{ secrets.GOOGLECLIENTID }} \ - -e OAUTH_GOOGLECLIENTSECRET=${{ secrets.GOOGLECLIENTSECRET }} \ - -e OAUTH_GOOGLEREDIRECTURL=${{ secrets.GOOGLEREDIRECTURL }} \ - -e OAUTH_GOOGLEAUTHTOKENURLHOST=${{ secrets.GOOGLEAUTHTOKENURLHOST }} \ - -e OAUTH_GOOGLEUSERURLHOST=${{ secrets.GOOGLEUSERURLHOST }} \ -e SPRING_JPA_HIBERNATE_DDL_AUTO=validate \ - -e AWS_S3_ACCESS_KEY=${{ secrets.AWS_S3_ACCESS_KEY }} \ - -e AWS_S3_SECRET_KEY=${{ secrets.AWS_S3_SECRET_KEY }} \ - -e AWS_S3_BUCKET_NAME=${{ secrets.PROD_AWS_S3_BUCKET_NAME }} \ - -e AWS_S3_BASICPROFILEIMAGEURL=${{ secrets.BASICPROFILEIMAGEURL }} \ + -e SPRING_CREDENTIALS_ACCESS_KEY=${{secrets.AWS_S3_ACCESS_KEY}} \ + -e SPRING_CREDENTIALS_SECRET_KEY=${{secrets.AWS_S3_SECRET_KEY}} \ -e TZ=Asia/Seoul \ - -e SENTRY_DSN=${{ secrets.SENTRY_DSN }} \ - -e SENTRY_ENABLE_TRACING=true \ - -e SENTRY_ENVIRONMENT=prod \ - -e LOKI_URL=${{ secrets.LOKI_SERVER_URL }} \ ${{ secrets.DOCKERHUB_USERNAME }}/spot-server:prod-${{ github.event.inputs.tag }} docker system prune -af \ No newline at end of file diff --git a/.gitignore b/.gitignore index 008d7ed9..e3ac083e 100644 --- a/.gitignore +++ b/.gitignore @@ -384,13 +384,5 @@ gradle-app.setting .env -*.application-jwt.yml -*.application-monitoring.yml -application-jwt.yml -application-oauth.yml -application-sentry.yml -application-aws.yaml -application-mixpanel.yaml - # 민성 레디스 바이너리 파일 -redis-server-7.2.3-mac-arm64 \ No newline at end of file +redis-server-7.2.3-mac-arm64 diff --git a/application/.gitignore b/application/.gitignore index fbcb1d18..01099eaf 100644 --- a/application/.gitignore +++ b/application/.gitignore @@ -41,7 +41,3 @@ bin/ ### Mac OS ### .DS_Store -*.application-jwt.yml - -### loki ### -**/application-monitoring.yml \ No newline at end of file diff --git a/application/src/main/java/org/depromeet/spot/application/common/jwt/JwtProperties.java b/application/src/main/java/org/depromeet/spot/application/common/jwt/JwtProperties.java index 28f76925..def7383b 100644 --- a/application/src/main/java/org/depromeet/spot/application/common/jwt/JwtProperties.java +++ b/application/src/main/java/org/depromeet/spot/application/common/jwt/JwtProperties.java @@ -1,6 +1,17 @@ package org.depromeet.spot.application.common.jwt; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.DependsOn; +import org.springframework.stereotype.Component; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@Component @ConfigurationProperties(prefix = "spring.jwt") -public record JwtProperties(String secret) {} +@DependsOn("awsSecretsManagerConfig") +public class JwtProperties { + String secret; +} diff --git a/application/src/main/java/org/depromeet/spot/application/common/jwt/JwtTokenUtil.java b/application/src/main/java/org/depromeet/spot/application/common/jwt/JwtTokenUtil.java index 8cf058cc..579fe6f3 100644 --- a/application/src/main/java/org/depromeet/spot/application/common/jwt/JwtTokenUtil.java +++ b/application/src/main/java/org/depromeet/spot/application/common/jwt/JwtTokenUtil.java @@ -59,13 +59,13 @@ public String generateToken(Long memberId, MemberRole memberRole) { .setClaims(createClaims(memberId, memberRole)) .setIssuedAt(current) .setExpiration(expiredAt) - .signWith(SignatureAlgorithm.HS256, properties.secret().getBytes()) + .signWith(SignatureAlgorithm.HS256, properties.getSecret().getBytes()) .compact(); } public Long getIdFromJWT(String token) { return Jwts.parser() - .setSigningKey(properties.secret().getBytes()) + .setSigningKey(properties.getSecret().getBytes()) .parseClaimsJws(token) .getBody() .get("memberId", Long.class); @@ -73,7 +73,7 @@ public Long getIdFromJWT(String token) { public String getRoleFromJWT(String token) { return Jwts.parser() - .setSigningKey(properties.secret().getBytes()) + .setSigningKey(properties.getSecret().getBytes()) .parseClaimsJws(token) .getBody() .get("role", String.class); @@ -122,7 +122,7 @@ private Map createClaims(Long memberId, MemberRole role) { } private Key createSignature() { - byte[] apiKeySecretBytes = properties.secret().getBytes(); + byte[] apiKeySecretBytes = properties.getSecret().getBytes(); return new SecretKeySpec(apiKeySecretBytes, SignatureAlgorithm.HS256.getJcaName()); } diff --git a/application/src/main/resources/appenders/console-appender.xml b/application/src/main/resources/appenders/console-appender.xml index 97295287..4f77452c 100644 --- a/application/src/main/resources/appenders/console-appender.xml +++ b/application/src/main/resources/appenders/console-appender.xml @@ -13,7 +13,7 @@ - http://${LOKI_URL}:3100/loki/api/v1/push + http://${loki.url}:3100/loki/api/v1/push