From 4cc6cec6dedfef6b7e9f054b139f35b39f6fd453 Mon Sep 17 00:00:00 2001 From: BYEONGRYEOL Date: Tue, 3 Sep 2024 20:42:34 +0900 Subject: [PATCH 1/5] =?UTF-8?q?Fix:=20=ED=86=A0=ED=81=B0=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=98=A4=EB=A5=98=20=EB=A9=94=EC=84=B8=EC=A7=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/gt/genti/jwt/JwtTokenProvider.java | 4 ++-- .../src/main/java/com/gt/genti/error/ResponseCode.java | 8 ++++---- .../main/java/com/gt/genti/discord/DiscordAppender.java | 5 ++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/genti-auth/src/main/java/com/gt/genti/jwt/JwtTokenProvider.java b/genti-auth/src/main/java/com/gt/genti/jwt/JwtTokenProvider.java index 493f91ad..87a026c3 100644 --- a/genti-auth/src/main/java/com/gt/genti/jwt/JwtTokenProvider.java +++ b/genti-auth/src/main/java/com/gt/genti/jwt/JwtTokenProvider.java @@ -110,7 +110,7 @@ public Long getUserIdFromRefreshToken(String refreshToken) { Long userId = getUserFromJwt(refreshToken); String foundRefreshToken = redisTemplate.opsForValue().get(userId.toString()); if (foundRefreshToken == null) { - throw ExpectedException.withLogging(ResponseCode.REFRESH_TOKEN_NOT_EXISTS); + throw ExpectedException.withoutLogging(ResponseCode.REFRESH_TOKEN_NOT_EXISTS); } if (!refreshToken.substring(JWT_PREFIX.length()).equals(foundRefreshToken)) { throw ExpectedException.withLogging(ResponseCode.REFRESH_TOKEN_INVALID); @@ -138,7 +138,7 @@ public void validateToken(String token) { } catch (MalformedJwtException | IllegalArgumentException | UnsupportedJwtException | SignatureException e) { throw ExpectedException.withLogging(ResponseCode.INVALID_TOKEN); } catch (ExpiredJwtException e) { - throw ExpectedException.withLogging(TOKEN_EXPIRED); + throw ExpectedException.withoutLogging(TOKEN_EXPIRED); } } diff --git a/genti-common/src/main/java/com/gt/genti/error/ResponseCode.java b/genti-common/src/main/java/com/gt/genti/error/ResponseCode.java index aa5fff2c..b7c2ac24 100644 --- a/genti-common/src/main/java/com/gt/genti/error/ResponseCode.java +++ b/genti-common/src/main/java/com/gt/genti/error/ResponseCode.java @@ -25,7 +25,7 @@ public enum ResponseCode { * 인증/인가 */ TOKEN_NOT_PROVIDED(ErrorConstants.TOKEN_NOT_PROVIDED, HttpStatus.UNAUTHORIZED, false, "토큰이 전달되지 않았습니다."), - TOKEN_EXPIRED(ErrorConstants.TOKEN_EXPIRED, HttpStatus.UNAUTHORIZED, false, "토큰이 만료되었습니다."), + TOKEN_EXPIRED(ErrorConstants.TOKEN_EXPIRED, HttpStatus.UNAUTHORIZED, false, "액세스 토큰이 만료되었습니다."), INVALID_TOKEN(ErrorConstants.INVALID_TOKEN, HttpStatus.UNAUTHORIZED, false, "유효하지 않은 토큰입니다."), INSUFFICIENT_PERMISSIONS(ErrorConstants.INSUFFICIENT_PERMISSIONS, HttpStatus.FORBIDDEN, false, "접근 권한이 부족합니다."), REFRESH_TOKEN_EXPIRED(ErrorConstants.REFRESH_TOKEN_EXPIRED, HttpStatus.UNAUTHORIZED, false, "리프레시 토큰이 만료되었습니다."), @@ -116,9 +116,9 @@ public enum ResponseCode { false, "사진생성요청을 요청한 유저만 볼 수 있습니다."), PictureGenerateRequestAlreadyProcessed(ErrorConstants.PictureGenerateRequestAlreadyProcessed, - BAD_REQUEST, - false, - "사진생성요청이 이미 처리중입니다."), + BAD_REQUEST, + false, + "사진생성요청이 이미 처리중입니다."), /** * User */ diff --git a/genti-external/src/main/java/com/gt/genti/discord/DiscordAppender.java b/genti-external/src/main/java/com/gt/genti/discord/DiscordAppender.java index 47a3a4bf..9802bb60 100644 --- a/genti-external/src/main/java/com/gt/genti/discord/DiscordAppender.java +++ b/genti-external/src/main/java/com/gt/genti/discord/DiscordAppender.java @@ -6,6 +6,7 @@ import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Map; +import java.util.Objects; import org.apache.commons.text.StringEscapeUtils; import org.springframework.beans.factory.annotation.Value; @@ -43,11 +44,13 @@ public class DiscordAppender extends UnsynchronizedAppenderBase { private String username = "Error log"; private String adminAvatarUrl = "https://img.icons8.com/ios-filled/50/FA5252/business.png"; private String errorAvatarUrl = "https://img.icons8.com/ios-filled/50/22C3E6/error--v1.png"; + private String devErrorAvatarUrl = "https://img.icons8.com/ios-filled/50/FFFFFF/error--v1.png"; private String eventAvatarUrl = "https://img.icons8.com/ios-filled/50/40C057/confetti.png"; @Override protected void append(ILoggingEvent eventObject) { - DiscordWebHook discordWebhook = new DiscordWebHook(username, errorAvatarUrl, false); + String avatarUrl = Objects.equals(profile, "staging") ? devErrorAvatarUrl : errorAvatarUrl; + DiscordWebHook discordWebhook = new DiscordWebHook(username, avatarUrl, false); Map mdcPropertyMap = eventObject.getMDCPropertyMap(); Color messageColor = getLevelColor(eventObject); From 161dd096e1e7c1b88113c77dc9a7795cd0300c45 Mon Sep 17 00:00:00 2001 From: BYEONGRYEOL Date: Tue, 3 Sep 2024 20:55:22 +0900 Subject: [PATCH 2/5] =?UTF-8?q?Fix:=20=ED=86=A0=ED=81=B0=20=EA=B4=80?= =?UTF-8?q?=EB=A0=A8=20=EC=98=A4=EB=A5=98=20=EB=A9=94=EC=84=B8=EC=A7=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- genti-auth/src/main/java/com/gt/genti/jwt/JwtTokenProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/genti-auth/src/main/java/com/gt/genti/jwt/JwtTokenProvider.java b/genti-auth/src/main/java/com/gt/genti/jwt/JwtTokenProvider.java index 87a026c3..3fb4633a 100644 --- a/genti-auth/src/main/java/com/gt/genti/jwt/JwtTokenProvider.java +++ b/genti-auth/src/main/java/com/gt/genti/jwt/JwtTokenProvider.java @@ -110,7 +110,7 @@ public Long getUserIdFromRefreshToken(String refreshToken) { Long userId = getUserFromJwt(refreshToken); String foundRefreshToken = redisTemplate.opsForValue().get(userId.toString()); if (foundRefreshToken == null) { - throw ExpectedException.withoutLogging(ResponseCode.REFRESH_TOKEN_NOT_EXISTS); + throw ExpectedException.withLogging(ResponseCode.REFRESH_TOKEN_NOT_EXISTS); } if (!refreshToken.substring(JWT_PREFIX.length()).equals(foundRefreshToken)) { throw ExpectedException.withLogging(ResponseCode.REFRESH_TOKEN_INVALID); From 26a5930e279aa969eb5ca13cb8c7743e1a889d71 Mon Sep 17 00:00:00 2001 From: BYEONGRYEOL Date: Tue, 3 Sep 2024 22:03:37 +0900 Subject: [PATCH 3/5] =?UTF-8?q?accesstoekn=2010=EC=B4=88=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/gt/genti/constants/JWTConstants.java | 2 +- set-actions-secret.ps1 | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 set-actions-secret.ps1 diff --git a/genti-common/src/main/java/com/gt/genti/constants/JWTConstants.java b/genti-common/src/main/java/com/gt/genti/constants/JWTConstants.java index d081e6f0..e12aa303 100644 --- a/genti-common/src/main/java/com/gt/genti/constants/JWTConstants.java +++ b/genti-common/src/main/java/com/gt/genti/constants/JWTConstants.java @@ -9,7 +9,7 @@ public class JWTConstants { public static final String ROLE = "role"; public static final String JWT_HEADER = "Authorization"; public static final String JWT_PREFIX = "Bearer "; - public static final Long ACCESS_TOKEN_EXPIRATION_TIME = 60 * 20 * 1000L; + public static final Long ACCESS_TOKEN_EXPIRATION_TIME = 10 * 1000L; public static final Long REFRESH_TOKEN_EXPIRATION_TIME = 60 * 60 * 24 * 7 * 2 * 1000L; } \ No newline at end of file diff --git a/set-actions-secret.ps1 b/set-actions-secret.ps1 new file mode 100644 index 00000000..32dc7db5 --- /dev/null +++ b/set-actions-secret.ps1 @@ -0,0 +1,17 @@ +# Set GitHub secrets using PowerShell + +$files = @{ + "DOCKER_COMPOSE_DEPLOY" = "./docker/deploy/docker-compose.yml" + "DOCKER_COMPOSE_STAGING" = "./docker/staging/docker-compose.yml" + "APPLICATION_DEPLOY" = "./genti-api/src/main/resources/application-deploy.yaml" + "APPLICATION_SECRET" = "./genti-api/src/main/resources/application-secret.yaml" + "APPLICATION_STAGING" = "./genti-api/src/main/resources/application-staging.yaml" +} + +foreach ($secretName in $files.Keys) { + $filePath = $files[$secretName] + $content = Get-Content -Path $filePath -Raw + gh secret set $secretName -b"$content" +} + +curl https://discord.com/api/webhooks/1280150154510602381/u-noRMoiACzAKzcQL1JdWrP-CcUfcJsJlvRahRBSQoPFopFhRqBuLrZaNG58uYmq79Ur \ No newline at end of file From 2705df7d718250659751e4cdce68fe3248a8a87e Mon Sep 17 00:00:00 2001 From: BYEONGRYEOL Date: Wed, 4 Sep 2024 20:31:15 +0900 Subject: [PATCH 4/5] =?UTF-8?q?Fix:=20=EC=9A=94=EC=B2=AD=EC=9D=B4=20?= =?UTF-8?q?=EC=96=B4=EB=93=9C=EB=AF=BC=EC=97=90=EA=B2=8C=20=EB=A7=A4?= =?UTF-8?q?=EC=B9=AD=EB=90=98=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20=ED=94=84?= =?UTF-8?q?=EB=A1=AC=ED=94=84=ED=8A=B8=EB=8F=84=20=EC=A0=84=EC=86=A1?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../picturegeneraterequest/service/RequestMatchService.java | 4 +++- .../src/main/java/com/gt/genti/constants/JWTConstants.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/service/RequestMatchService.java b/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/service/RequestMatchService.java index 8ddd378a..b321f6de 100644 --- a/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/service/RequestMatchService.java +++ b/genti-api/src/main/java/com/gt/genti/picturegeneraterequest/service/RequestMatchService.java @@ -126,7 +126,9 @@ private void matchRequestToAdmin(PictureGenerateRequest pgr, Creator adminCreato adminCreator.addPictureGenerateResponse(newPGRES); pgresList.add(newPGRES); gentiMatchResult.addMatchResult( - "email : %s가 요청한 id : %d 요청을 어드민에게 매칭".formatted(pgr.getRequester().getEmail(), pgr.getId())); + "[요청자 email] : %s [요청자 id] : %d [작업자 email] : %s [작업자 id] : %d [프롬프트] : %s [비율] : %s [앵글] : %s ".formatted( + pgr.getRequester().getEmail(), pgr.getId(), adminCreator.getUser().getEmail(), adminCreator.getId(), + pgr.getPrompt(), pgr.getPictureRatio().getResponse(), pgr.getCameraAngle().getResponse())); } private void matchRequestToCreator(PictureGenerateRequest pgr, Creator creator, GentiMatchResult gentiMatchResult) { diff --git a/genti-common/src/main/java/com/gt/genti/constants/JWTConstants.java b/genti-common/src/main/java/com/gt/genti/constants/JWTConstants.java index e12aa303..d081e6f0 100644 --- a/genti-common/src/main/java/com/gt/genti/constants/JWTConstants.java +++ b/genti-common/src/main/java/com/gt/genti/constants/JWTConstants.java @@ -9,7 +9,7 @@ public class JWTConstants { public static final String ROLE = "role"; public static final String JWT_HEADER = "Authorization"; public static final String JWT_PREFIX = "Bearer "; - public static final Long ACCESS_TOKEN_EXPIRATION_TIME = 10 * 1000L; + public static final Long ACCESS_TOKEN_EXPIRATION_TIME = 60 * 20 * 1000L; public static final Long REFRESH_TOKEN_EXPIRATION_TIME = 60 * 60 * 24 * 7 * 2 * 1000L; } \ No newline at end of file From 14453ccbff5eda42c0c8c2421caece9b8ca98720 Mon Sep 17 00:00:00 2001 From: LeeJaehyung <122717063+LeeJae-H@users.noreply.github.com> Date: Wed, 4 Sep 2024 20:47:26 +0900 Subject: [PATCH 5/5] =?UTF-8?q?Delete:=20action-secret=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- set-actions-secret.ps1 | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 set-actions-secret.ps1 diff --git a/set-actions-secret.ps1 b/set-actions-secret.ps1 deleted file mode 100644 index 32dc7db5..00000000 --- a/set-actions-secret.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -# Set GitHub secrets using PowerShell - -$files = @{ - "DOCKER_COMPOSE_DEPLOY" = "./docker/deploy/docker-compose.yml" - "DOCKER_COMPOSE_STAGING" = "./docker/staging/docker-compose.yml" - "APPLICATION_DEPLOY" = "./genti-api/src/main/resources/application-deploy.yaml" - "APPLICATION_SECRET" = "./genti-api/src/main/resources/application-secret.yaml" - "APPLICATION_STAGING" = "./genti-api/src/main/resources/application-staging.yaml" -} - -foreach ($secretName in $files.Keys) { - $filePath = $files[$secretName] - $content = Get-Content -Path $filePath -Raw - gh secret set $secretName -b"$content" -} - -curl https://discord.com/api/webhooks/1280150154510602381/u-noRMoiACzAKzcQL1JdWrP-CcUfcJsJlvRahRBSQoPFopFhRqBuLrZaNG58uYmq79Ur \ No newline at end of file