Skip to content

Commit

Permalink
fest : 애플 로그인 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
1000kkannoo committed Aug 10, 2024
1 parent d35cdc6 commit b269f8f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -47,10 +50,10 @@ public CustomResponseEntity<Void> updateAge(
}

/**
* @apiNote 인슈보딩 입력 API
* @param accountId
* @param request
* @return void
* @apiNote 인슈보딩 입력 API
*/
@PatchMapping("/register/board")
public CustomResponseEntity<Void> updateInsureBoarding(
Expand All @@ -59,4 +62,26 @@ public CustomResponseEntity<Void> updateInsureBoarding(
) {
return CustomResponseEntity.success(accountService.updateInsureBoarding(accountId, request));
}

@PostMapping("/callback/apple")
public String test(
MultiValueMap<String, Object> 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;
}
}

0 comments on commit b269f8f

Please sign in to comment.