Skip to content

[TSK-29] feat: 백엔드 Google OAuth 로그인#11

Open
junzero741 wants to merge 9 commits intobackendfrom
TSK-29
Open

[TSK-29] feat: 백엔드 Google OAuth 로그인#11
junzero741 wants to merge 9 commits intobackendfrom
TSK-29

Conversation

@junzero741
Copy link
Collaborator

@junzero741 junzero741 commented Mar 24, 2026

Summary

  • Google OAuth ID 토큰 기반 회원가입/로그인 API 구현 (POST /auth/google)
  • Access Token (JWT) + Refresh Token (UUID, SHA256 해시 저장) 발급 체계 구축
  • 토큰 갱신 (POST /auth/refresh), 로그아웃 (POST /auth/logout), 프로필
    조회 (GET /auth/me) API 구현
  • User, ProviderAccount, RefreshToken Prisma 스키마 및 마이그레이션 추가
  • GoogleOAuthClient mock 기반 E2E 테스트 14건 작성

주요 결정 사항

  • 토큰 검증 방식: 서버에서 Google ID Token 직접 검증
    (google-auth-library)
    • Authorization Code 방식 대비 모바일 클라이언트 구현이 단순하고, 서버 간
      통신 없이 검증 가능
  • Refresh Token 저장: UUID 생성 → SHA256 해시를 DB에 저장
    • 원본 토큰은 클라이언트만 보유, DB 유출 시에도 토큰 탈취 불가
  • User ↔ ProviderAccount 관계: 1:N 관계
    • 추후 Apple, Kakao 등 소셜 로그인 추가 시 User 하나에 여러 Provider 연결
      가능
  • Repository 추상화: 추상 클래스 + Prisma 구현체 분리
    • 서비스 레이어가 Prisma에 직접 의존하지 않아 테스트 용이, ORM 교체 가능
  • 토큰 갱신 전략: Rotation (갱신 시 기존 토큰 revoke + 새 토큰 발급)
    • 탈취된 Refresh Token 재사용 방지

Test Plan

  • Unit TestAuthService, UserService 핵심 로직 테스트 (pnpm test)
  • E2E Test — GoogleOAuthClient mock 기반 전체 인증 흐름 테스트
    (pnpm test:e2e)
    • POST /auth/google — 신규 유저 회원가입, 기존 유저 재로그인,
      idToken 누락 400, Google 인증 실패 401
    • POST /auth/refresh — 정상 갱신, 사용된 토큰 재사용 401, 존재하지
      않는 토큰 401, 누락 400
    • GET /auth/me — 정상 조회, 토큰 없음 401, 잘못된 토큰 401
    • POST /auth/logout — 로그아웃 후 refresh 무효화, 토큰 없이 401
    • 통합 시나리오 — 회원가입 → 프로필 → 토큰 갱신 → 새 토큰으로
      프로필 → 로그아웃 → refresh 불가
      프론트엔드 연동 후 실제 연동테스트 예정

@junzero741 junzero741 requested a review from new-pow March 24, 2026 08:45
@junzero741 junzero741 self-assigned this Mar 24, 2026
junzero741 and others added 7 commits March 24, 2026 17:51
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
junzero741 and others added 2 commits March 24, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant