From e6685d4b27fc03d952610ebc1fd65211e390f6ad Mon Sep 17 00:00:00 2001 From: KWY Date: Wed, 26 Jun 2024 01:40:09 +0900 Subject: [PATCH 1/5] =?UTF-8?q?#270=20[fix]=20response=20dto=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit api 문서 수정으로 redirect url을 반환함에 따라 dto 수정 --- .../auth/dto/response/AuthorizationCodeResponse.java | 4 ---- .../operation/auth/dto/response/RedirectUrlResponse.java | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 operation-api/src/main/java/org/sopt/makers/operation/auth/dto/response/AuthorizationCodeResponse.java create mode 100644 operation-api/src/main/java/org/sopt/makers/operation/auth/dto/response/RedirectUrlResponse.java diff --git a/operation-api/src/main/java/org/sopt/makers/operation/auth/dto/response/AuthorizationCodeResponse.java b/operation-api/src/main/java/org/sopt/makers/operation/auth/dto/response/AuthorizationCodeResponse.java deleted file mode 100644 index 595c45fb..00000000 --- a/operation-api/src/main/java/org/sopt/makers/operation/auth/dto/response/AuthorizationCodeResponse.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.sopt.makers.operation.auth.dto.response; - -public record AuthorizationCodeResponse(String platformCode) { -} diff --git a/operation-api/src/main/java/org/sopt/makers/operation/auth/dto/response/RedirectUrlResponse.java b/operation-api/src/main/java/org/sopt/makers/operation/auth/dto/response/RedirectUrlResponse.java new file mode 100644 index 00000000..c45ffd85 --- /dev/null +++ b/operation-api/src/main/java/org/sopt/makers/operation/auth/dto/response/RedirectUrlResponse.java @@ -0,0 +1,4 @@ +package org.sopt.makers.operation.auth.dto.response; + +public record RedirectUrlResponse(String redirectUrl) { +} From 4295dae821490959251626302b2f70967f6dc343 Mon Sep 17 00:00:00 2001 From: KWY Date: Wed, 26 Jun 2024 01:43:19 +0900 Subject: [PATCH 2/5] =?UTF-8?q?#270=20[fix]=20response=20=EB=A9=94?= =?UTF-8?q?=EC=8B=9C=EC=A7=80=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../makers/operation/code/success/auth/AuthSuccessCode.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/operation-common/src/main/java/org/sopt/makers/operation/code/success/auth/AuthSuccessCode.java b/operation-common/src/main/java/org/sopt/makers/operation/code/success/auth/AuthSuccessCode.java index 9801b921..0b9131f5 100644 --- a/operation-common/src/main/java/org/sopt/makers/operation/code/success/auth/AuthSuccessCode.java +++ b/operation-common/src/main/java/org/sopt/makers/operation/code/success/auth/AuthSuccessCode.java @@ -10,7 +10,7 @@ @Getter @RequiredArgsConstructor public enum AuthSuccessCode implements SuccessCode { - SUCCESS_GET_AUTHORIZATION_CODE(OK, "플랫폼 인가코드 발급 성공"), + SUCCESS_RETURN_REDIRECT_URL_WITH_PLATFORM_CODE(OK, "플랫폼 인가코드를 포함한 redirect url 반환 성공"), SUCCESS_GENERATE_TOKEN(OK, "토큰 발급 성공"); private final HttpStatus status; private final String message; From 24e49b3a5b89397fa64cc25ceba15ce8f82d0ff0 Mon Sep 17 00:00:00 2001 From: KWY Date: Wed, 26 Jun 2024 01:44:26 +0900 Subject: [PATCH 3/5] =?UTF-8?q?#270=20[feat]=20response=20data=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit redirect url template을 상수로 만들어서 redirect uri와 platformCode를 redirctUrl 형태로 만든다 --- .../operation/auth/api/AuthApiController.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) 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 11669ebd..f5f8d00a 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 @@ -1,9 +1,24 @@ package org.sopt.makers.operation.auth.api; +import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.EXPIRED_PLATFORM_CODE; +import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.EXPIRED_REFRESH_TOKEN; +import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.INVALID_GRANT_TYPE; +import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.INVALID_SOCIAL_TYPE; +import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.NOT_FOUNT_REGISTERED_TEAM; +import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.NOT_NULL_CODE; +import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.NOT_NULL_GRANT_TYPE; +import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.NOT_NULL_REFRESH_TOKEN; +import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.USED_PLATFORM_CODE; +import static org.sopt.makers.operation.code.success.auth.AuthSuccessCode.SUCCESS_GENERATE_TOKEN; +import static org.sopt.makers.operation.code.success.auth.AuthSuccessCode.SUCCESS_RETURN_REDIRECT_URL_WITH_PLATFORM_CODE; +import static org.sopt.makers.operation.jwt.JwtTokenType.PLATFORM_CODE; +import static org.sopt.makers.operation.jwt.JwtTokenType.REFRESH_TOKEN; + +import java.util.concurrent.ConcurrentHashMap; import lombok.RequiredArgsConstructor; import lombok.val; import org.sopt.makers.operation.auth.dto.request.AccessTokenRequest; -import org.sopt.makers.operation.auth.dto.response.AuthorizationCodeResponse; +import org.sopt.makers.operation.auth.dto.response.RedirectUrlResponse; import org.sopt.makers.operation.auth.dto.response.TokenResponse; import org.sopt.makers.operation.auth.service.AuthService; import org.sopt.makers.operation.dto.BaseResponse; @@ -20,22 +35,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.concurrent.ConcurrentHashMap; - -import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.EXPIRED_PLATFORM_CODE; -import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.EXPIRED_REFRESH_TOKEN; -import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.INVALID_GRANT_TYPE; -import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.INVALID_SOCIAL_TYPE; -import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.NOT_FOUNT_REGISTERED_TEAM; -import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.NOT_NULL_CODE; -import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.NOT_NULL_GRANT_TYPE; -import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.NOT_NULL_REFRESH_TOKEN; -import static org.sopt.makers.operation.code.failure.auth.AuthFailureCode.USED_PLATFORM_CODE; -import static org.sopt.makers.operation.code.success.auth.AuthSuccessCode.SUCCESS_GENERATE_TOKEN; -import static org.sopt.makers.operation.code.success.auth.AuthSuccessCode.SUCCESS_GET_AUTHORIZATION_CODE; -import static org.sopt.makers.operation.jwt.JwtTokenType.PLATFORM_CODE; -import static org.sopt.makers.operation.jwt.JwtTokenType.REFRESH_TOKEN; - @RestController @RequiredArgsConstructor @RequestMapping("/api/v1/auth") @@ -43,6 +42,7 @@ public class AuthApiController implements AuthApi { private static final String AUTHORIZATION_CODE_GRANT_TYPE = "authorizationCode"; private static final String REFRESH_TOKEN_GRANT_TYPE = "refreshToken"; + private static final String REDIRECT_URL_WITH_CODE_TEMPLATE = "%s?code=%s"; private final ConcurrentHashMap tempPlatformCode; private final AuthService authService; @@ -65,7 +65,8 @@ public ResponseEntity> authorize( val userId = findUserIdBySocialTypeAndCode(type, code); val platformCode = generatePlatformCode(clientId, redirectUri, userId); - return ApiResponseUtil.success(SUCCESS_GET_AUTHORIZATION_CODE, new AuthorizationCodeResponse(platformCode)); + val redirectUrl = String.format(REDIRECT_URL_WITH_CODE_TEMPLATE, redirectUri, platformCode); + return ApiResponseUtil.success(SUCCESS_RETURN_REDIRECT_URL_WITH_PLATFORM_CODE, new RedirectUrlResponse(redirectUrl)); } @Override From fa929522539434bdb392966a9a18ea38a02bef40 Mon Sep 17 00:00:00 2001 From: KWY Date: Wed, 26 Jun 2024 01:44:49 +0900 Subject: [PATCH 4/5] =?UTF-8?q?#270=20[test]=20/authorize=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../makers/operation/auth/api/AuthApiControllerTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/operation-api/src/test/java/org/sopt/makers/operation/auth/api/AuthApiControllerTest.java b/operation-api/src/test/java/org/sopt/makers/operation/auth/api/AuthApiControllerTest.java index 02778b7b..9cc70ff5 100644 --- a/operation-api/src/test/java/org/sopt/makers/operation/auth/api/AuthApiControllerTest.java +++ b/operation-api/src/test/java/org/sopt/makers/operation/auth/api/AuthApiControllerTest.java @@ -53,7 +53,7 @@ class SuccessTest { @DisplayName("유효한 type, code, clientId, redirectUri 값이 들어왔을 때, 플랫폼 인가코드를 반환한다.") @ParameterizedTest @CsvSource({ - "APPLE,code,clientId,redirectUri" + "APPLE,code,clientId,https://localhost:8080/auth/redirectUri" }) void successTest(String type, String code, String clientId, String redirectUri) throws Exception { // given @@ -71,7 +71,8 @@ void successTest(String type, String code, String clientId, String redirectUri) .param("clientId", clientId) .param("redirectUri", redirectUri)) .andExpect(status().isOk()) - .andExpect(jsonPath("$.message").value("플랫폼 인가코드 발급 성공")); + .andExpect(jsonPath("$.message").value("플랫폼 인가코드를 포함한 redirect url 반환 성공")) + .andExpect(jsonPath("$.data.redirectUrl").value("https://localhost:8080/auth/redirectUri?code=Platform Code")); } @DisplayName("grantType 이 authorizationCode 이고, 유효한 clientId, redirectUri, code 값이 들어왔을 때, 액세스 토큰과 리프레시 토큰을 발급한다.") From 0859f5d06a7264628276fc7528718dfd1c44a697 Mon Sep 17 00:00:00 2001 From: KWY Date: Wed, 26 Jun 2024 19:05:35 +0900 Subject: [PATCH 5/5] =?UTF-8?q?#270=20[chore]=20template=EC=97=90=EC=84=9C?= =?UTF-8?q?=20format=EC=9C=BC=EB=A1=9C=20=EC=83=81=EC=88=98=EB=AA=85=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 --- .../org/sopt/makers/operation/auth/api/AuthApiController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 f5f8d00a..5bb181ab 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 @@ -42,7 +42,7 @@ public class AuthApiController implements AuthApi { private static final String AUTHORIZATION_CODE_GRANT_TYPE = "authorizationCode"; private static final String REFRESH_TOKEN_GRANT_TYPE = "refreshToken"; - private static final String REDIRECT_URL_WITH_CODE_TEMPLATE = "%s?code=%s"; + private static final String REDIRECT_URL_WITH_CODE_FORMAT = "%s?code=%s"; private final ConcurrentHashMap tempPlatformCode; private final AuthService authService; @@ -65,7 +65,7 @@ public ResponseEntity> authorize( val userId = findUserIdBySocialTypeAndCode(type, code); val platformCode = generatePlatformCode(clientId, redirectUri, userId); - val redirectUrl = String.format(REDIRECT_URL_WITH_CODE_TEMPLATE, redirectUri, platformCode); + val redirectUrl = String.format(REDIRECT_URL_WITH_CODE_FORMAT, redirectUri, platformCode); return ApiResponseUtil.success(SUCCESS_RETURN_REDIRECT_URL_WITH_PLATFORM_CODE, new RedirectUrlResponse(redirectUrl)); }