Skip to content

Commit

Permalink
Merge pull request #106 from Donut-DONationUTile/hotfix/googleid
Browse files Browse the repository at this point in the history
hotfix: 토큰 검증 로직 변경
  • Loading branch information
Ganghee-Lee-0522 authored Nov 27, 2024
2 parents fd92657 + 3c82639 commit 75d8c6b
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions src/main/java/zero/eight/donut/service/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,30 +164,31 @@ private GoogleIdToken verifyEmail(String googleToken) {
}
*/

GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(new NetHttpTransport(), new JacksonFactory())
// Specify the CLIENT_ID of the app that accesses the backend:
.setAudience(Collections.singletonList(CLIENT_ID))
// Or, if multiple clients access the backend:
//.setAudience(Arrays.asList(CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3))
.build();
log.info("verifier 생성 -> {}", String.valueOf(verifier));

try {
idToken = verifier.verify(googleToken);
} catch (GeneralSecurityException | IOException e) {
throw new RuntimeException(e);
}
// GoogleIdTokenVerifier verifier = new GoogleIdTokenVerifier.Builder(new NetHttpTransport(), new JacksonFactory())
// // Specify the CLIENT_ID of the app that accesses the backend:
// .setAudience(Collections.singletonList(CLIENT_ID))
// // Or, if multiple clients access the backend:
// //.setAudience(Arrays.asList(CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3))
// .build();
// log.info("verifier 생성 -> {}", String.valueOf(verifier));
//
// try {
//
// idToken = verifier.verify(googleToken);
// } catch (GeneralSecurityException | IOException e) {
// throw new RuntimeException(e);
// }


if (idToken != null) {

log.info("idToken is not null");
GoogleIdToken.Payload payload = idToken.getPayload();

// if (!tokenVerifier(payload)) {
// log.info("token 검증 결과 유효하지 않음");
// return null;
// }
if (!tokenVerifier(payload)) {
log.info("token 검증 결과 유효하지 않음");
return null;
}

// Print user identifier
String googleId = payload.getSubject();
Expand Down

0 comments on commit 75d8c6b

Please sign in to comment.