From b269f8fa5702a360782f01cf67a082ecd553fae0 Mon Sep 17 00:00:00 2001 From: Hyun Woo Date: Sun, 11 Aug 2024 02:48:36 +0900 Subject: [PATCH] =?UTF-8?q?fest=20:=20=EC=95=A0=ED=94=8C=20=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 1 + .../account/controller/AccountController.java | 27 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1589710..7397457 100644 --- a/build.gradle +++ b/build.gradle @@ -82,6 +82,7 @@ dependencies { implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.5' runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.5' runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.5' + implementation group: 'com.nimbusds', name: 'nimbus-jose-jwt', version: '3.10' // Redis implementation('org.springframework.boot:spring-boot-starter-data-redis') diff --git a/src/main/java/cmc15/backend/domain/account/controller/AccountController.java b/src/main/java/cmc15/backend/domain/account/controller/AccountController.java index 332c7f0..e9ed4ae 100644 --- a/src/main/java/cmc15/backend/domain/account/controller/AccountController.java +++ b/src/main/java/cmc15/backend/domain/account/controller/AccountController.java @@ -4,9 +4,12 @@ import cmc15.backend.domain.account.response.AccountResponse; import cmc15.backend.domain.account.service.AccountService; import cmc15.backend.global.CustomResponseEntity; +import com.nimbusds.jwt.ReadOnlyJWTClaimsSet; +import com.nimbusds.jwt.SignedJWT; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.*; @RestController @@ -47,10 +50,10 @@ public CustomResponseEntity updateAge( } /** - * @apiNote 인슈보딩 입력 API * @param accountId * @param request * @return void + * @apiNote 인슈보딩 입력 API */ @PatchMapping("/register/board") public CustomResponseEntity updateInsureBoarding( @@ -59,4 +62,26 @@ public CustomResponseEntity updateInsureBoarding( ) { return CustomResponseEntity.success(accountService.updateInsureBoarding(accountId, request)); } + + @PostMapping("/callback/apple") + public String test( + MultiValueMap request + ) { + // 전달 받은 data에서 token 값 저장 + String id_token = request.get("id_token").toString(); + String email = ""; + try { + //token값 decode처리 + SignedJWT signedJWT = SignedJWT.parse(id_token); + //token값에서 payload 저장 + ReadOnlyJWTClaimsSet payload = signedJWT.getJWTClaimsSet(); + //payload에서 email 값 저장 + email = payload.getClaim("email").toString(); + + } catch (Exception e) { + e.printStackTrace(); + } + + return email; + } }