diff --git a/operation-api/src/main/java/org/sopt/makers/operation/auth/api/AuthApiController.java b/operation-api/src/main/java/org/sopt/makers/operation/auth/api/AuthApiController.java index 05e05be2..e7f78b5f 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/auth/api/AuthApiController.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/auth/api/AuthApiController.java @@ -40,7 +40,7 @@ public ResponseEntity> authorize( if (!SocialType.isContains(type)) throw new AuthException(INVALID_SOCIAL_TYPE); val userId = findUserIdBySocialTypeAndCode(type, code); - val platformCode = generatePlatformCode(userId); + val platformCode = generatePlatformCode(clientId, redirectUri, userId); return ApiResponseUtil.success(SUCCESS_GET_AUTHORIZATION_CODE, new AuthorizationCodeResponse(platformCode)); } @@ -57,8 +57,8 @@ private Long findUserIdBySocialTypeAndCode(String type, String code) { return authService.getUserId(socialType, userSocialId); } - private String generatePlatformCode(Long userId) { - val platformCode = authService.generatePlatformCode(userId); + private String generatePlatformCode(String clientId, String redirectUri, Long userId) { + val platformCode = authService.generatePlatformCode(clientId, redirectUri, userId); tempPlatformCode.putIfAbsent(platformCode, platformCode); return platformCode; } diff --git a/operation-api/src/main/java/org/sopt/makers/operation/auth/service/AuthService.java b/operation-api/src/main/java/org/sopt/makers/operation/auth/service/AuthService.java index 3464ef0e..aca12053 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/auth/service/AuthService.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/auth/service/AuthService.java @@ -9,5 +9,5 @@ public interface AuthService { Long getUserId(SocialType socialType, String userSocialId); - String generatePlatformCode(Long userId); + String generatePlatformCode(String clientId, String redirectUri, Long userId); } diff --git a/operation-api/src/main/java/org/sopt/makers/operation/auth/service/AuthServiceImpl.java b/operation-api/src/main/java/org/sopt/makers/operation/auth/service/AuthServiceImpl.java index f62ce1d3..f7dff82c 100644 --- a/operation-api/src/main/java/org/sopt/makers/operation/auth/service/AuthServiceImpl.java +++ b/operation-api/src/main/java/org/sopt/makers/operation/auth/service/AuthServiceImpl.java @@ -50,7 +50,7 @@ public Long getUserId(SocialType socialType, String userSocialId) { } @Override - public String generatePlatformCode(Long userId) { + public String generatePlatformCode(String clientId, String redirectUri, Long userId) { val platformCodeSecretKey = valueConfig.getPlatformCodeSecretKey(); val signatureAlgorithm = SignatureAlgorithm.HS256; @@ -59,6 +59,8 @@ public String generatePlatformCode(Long userId) { val exp = new Date().toInstant().atZone(KST) .toLocalDateTime().plusMinutes(5).atZone(KST).toInstant(); return Jwts.builder() + .setIssuer(clientId) + .setAudience(redirectUri) .setSubject(Long.toString(userId)) .setExpiration(Date.from(exp)) .signWith(signingKey, signatureAlgorithm)