From 7c9d384382c0409a73e644d9d8460acd7ba0ee56 Mon Sep 17 00:00:00 2001 From: wuseong Date: Thu, 8 Feb 2024 00:22:10 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20post=20=EC=9A=94=EC=B2=AD=EC=9D=B8?= =?UTF-8?q?=EB=8D=B0=20get=EC=9C=BC=EB=A1=9C=20=ED=95=98=EA=B3=A0=20?= =?UTF-8?q?=EC=9E=88=EB=8D=98=20=EA=B1=B0=20=EC=88=98=EC=A0=95..=20?= =?UTF-8?q?=EC=99=80..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../onnoff/auth/feignClient/client/AppleAuthClient.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/onnoff/onnoff/auth/feignClient/client/AppleAuthClient.java b/src/main/java/com/onnoff/onnoff/auth/feignClient/client/AppleAuthClient.java index 58d30c3..165d31d 100644 --- a/src/main/java/com/onnoff/onnoff/auth/feignClient/client/AppleAuthClient.java +++ b/src/main/java/com/onnoff/onnoff/auth/feignClient/client/AppleAuthClient.java @@ -6,14 +6,18 @@ import org.springframework.cloud.openfeign.FeignClient; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.Map; @FeignClient(name = "apple-auth-client",url = "https://appleid.apple.com/auth") public interface AppleAuthClient{ @GetMapping("/keys") JwkResponse.JwkSet getKeys(); - @GetMapping(value = "/token", consumes = "application/x-www-form-urlencoded") - TokenResponse getToken(MultiValueMap requestBody); + @PostMapping(value = "/token", consumes = "application/x-www-form-urlencoded") + TokenResponse getToken(@RequestBody Map requestBody); //회원 탈퇴 메서드 // @GetMapping("/revoke") From bf8c30ee82d22bab193dcaeadbe36ee9194493aa Mon Sep 17 00:00:00 2001 From: wuseong Date: Thu, 8 Feb 2024 00:23:32 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=EB=B3=B8=EB=AC=B8=20form-urlencode?= =?UTF-8?q?d=20=ED=83=80=EC=9E=85=EC=9C=BC=EB=A1=9C=20=EC=9A=94=EC=B2=AD?= =?UTF-8?q?=20=EB=B3=B4=EB=82=BC=20=EC=88=98=20=EC=9E=88=EB=8F=84=EB=A1=9D?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../onnoff/auth/feignClient/config/FeignConfig.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/onnoff/onnoff/auth/feignClient/config/FeignConfig.java b/src/main/java/com/onnoff/onnoff/auth/feignClient/config/FeignConfig.java index d004260..bea47fb 100644 --- a/src/main/java/com/onnoff/onnoff/auth/feignClient/config/FeignConfig.java +++ b/src/main/java/com/onnoff/onnoff/auth/feignClient/config/FeignConfig.java @@ -2,9 +2,14 @@ import com.onnoff.onnoff.auth.feignClient.CustomErrorDecoder; +import feign.codec.Encoder; import feign.codec.ErrorDecoder; +import feign.form.spring.SpringFormEncoder; +import org.springframework.boot.autoconfigure.http.HttpMessageConverters; +import org.springframework.cloud.openfeign.support.SpringEncoder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; @Configuration public class FeignConfig { @@ -12,4 +17,8 @@ public class FeignConfig { public ErrorDecoder errorDecoder(){ return new CustomErrorDecoder(); } + @Bean + public Encoder multipartFormEncoder() { + return new SpringFormEncoder(new SpringEncoder(() -> new HttpMessageConverters(new RestTemplate().getMessageConverters()))); + } } From 252904fde524c97f59446642ce3c8535222ecf36 Mon Sep 17 00:00:00 2001 From: wuseong Date: Thu, 8 Feb 2024 00:25:38 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20deprecated=20=EB=90=9C=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EA=B5=90=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/service/AppleLoginService.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/onnoff/onnoff/auth/service/AppleLoginService.java b/src/main/java/com/onnoff/onnoff/auth/service/AppleLoginService.java index 02a4bd5..725a037 100644 --- a/src/main/java/com/onnoff/onnoff/auth/service/AppleLoginService.java +++ b/src/main/java/com/onnoff/onnoff/auth/service/AppleLoginService.java @@ -9,14 +9,12 @@ import com.onnoff.onnoff.domain.user.User; import com.onnoff.onnoff.domain.user.enums.SocialType; import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.bouncycastle.asn1.pkcs.PrivateKeyInfo; import org.bouncycastle.openssl.PEMParser; import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter; import org.springframework.beans.factory.annotation.Value; -import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; import org.springframework.util.MultiValueMap; @@ -52,6 +50,7 @@ public class AppleLoginService implements LoginService{ public TokenResponse getAccessTokenByCode(String code) { // client secret 만들기 String clientSecret = createClientSecret(); + log.info("clientSecret = {}", clientSecret); // 요청 MultiValueMap urlEncoded = TokenRequest.builder() .clientId(clientId) @@ -63,21 +62,23 @@ public TokenResponse getAccessTokenByCode(String code) { } private String createClientSecret() { Date expirationDate = Date.from(LocalDateTime.now().plusDays(30).atZone(ZoneId.systemDefault()).toInstant()); - Map jwtHeader = new HashMap<>(); - jwtHeader.put("kid", kid); - jwtHeader.put("alg", "ES256"); try { log.info("teamId = {}", teamId); log.info("kid = {}", kid); return Jwts.builder() - .setHeaderParams(jwtHeader) - .setIssuer(teamId) // 토큰 발행자 = 우리 팀 - .setIssuedAt(new Date(System.currentTimeMillis())) // 발행 시간 - UNIX 시간 - .setExpiration(expirationDate) // 만료 시간 - .setAudience(iss) // 애플이 수신자 - .setSubject(clientId) // 토큰의 주체 = 우리 앱 - .signWith(SignatureAlgorithm.ES256, getPrivateKey()) + .header() + .keyId(kid) + .add("alg", "ES256") + .and() + .subject(clientId) // 토큰의 주체 = 우리 앱 + .issuer(teamId) + .issuedAt(new Date(System.currentTimeMillis())) + .expiration(expirationDate) // 만료 시간 + .audience() + .add(iss) + .and() + .signWith(getPrivateKey(), Jwts.SIG.ES256) .compact(); } catch (IOException e) { throw new RuntimeException(e);