Skip to content

Commit

Permalink
Merge pull request #251 from boostcampwm2023/fix/idtoken_verify_conflict
Browse files Browse the repository at this point in the history
소셜 Id토큰 검증 충돌 해결
  • Loading branch information
5tarry authored Dec 11, 2023
2 parents e547dab + 570bcc6 commit 6bd5f08
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions server/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ import axios from 'axios';
import { InvalidKakaoIdTokenException } from 'src/exceptions/invalid-kakao-idtoken.exception';
import { InconsistentKakaoUuidException } from 'src/exceptions/inconsistent-kakao-uuid.exception';
import { createPublicKey } from 'crypto';
import { PlatformEnum, SignupRequestDto } from './dto/signup-request.dto';
import { OAuth2Client } from 'google-auth-library';
import { InvalidGoogldIdTokenException } from 'src/exceptions/invalid-google-idToken.exception';
import { InconsistentGoogldUuidException } from 'src/exceptions/inconsistent-google-uuid.exception';
import { SignupRequestDto } from './dto/signup-request.dto';
import { PlatformEnum, SignupRequestDto } from './dto/signup-request.dto';
import { JwtDto } from './dto/jwt.dto';
import { SignupResponseDto } from './dto/signup-response.dto';
import { SigninResponseDto } from './dto/signin-response.dto';
Expand Down Expand Up @@ -148,6 +147,10 @@ export class AuthService {

async verifyUuid(platform: PlatformEnum, idToken: string, uuid: string) {
switch (platform) {
case PlatformEnum.GOOGLE:
if (uuid !== (await this.verifyGoogleIdToken(idToken)))
throw new InconsistentGoogldUuidException();
break;
case PlatformEnum.KAKAO:
if (uuid !== (await this.verifyKakaoIdToken(idToken)))
throw new InconsistentKakaoUuidException();
Expand All @@ -168,16 +171,6 @@ export class AuthService {
);
}

async verifyUuid(platform: string, idToken: string, uuid: string) {
switch (platform) {
case 'GOOGLE':
if (uuid !== (await this.verifyGoogleIdToken(idToken)))
throw new InconsistentGoogldUuidException();
break;
default:
}
}

async verifyGoogleIdToken(idToken: string) {
const client = new OAuth2Client();

Expand All @@ -197,12 +190,4 @@ export class AuthService {
throw new InvalidGoogldIdTokenException();
}
}

formatAsUUID(mostSigBits, leastSigBits) {
const most = mostSigBits.toString('16').padStart(16, '0');
const least = leastSigBits.toString('16').padStart(16, '0');
return `${most.substring(0, 8)}-${most.substring(8, 12)}-${most.substring(
12,
)}-${least.substring(0, 4)}-${least.substring(4)}`;
}
}

0 comments on commit 6bd5f08

Please sign in to comment.