Skip to content

Refactor: 협업시 인증 추가#11

Merged
stoneTiger0912 merged 4 commits intomainfrom
refactor/add-collab-auth
Apr 2, 2026
Merged

Refactor: 협업시 인증 추가#11
stoneTiger0912 merged 4 commits intomainfrom
refactor/add-collab-auth

Conversation

@stoneTiger0912
Copy link
Copy Markdown
Member

@stoneTiger0912 stoneTiger0912 commented Apr 2, 2026

📝 변경 내용


✅ 체크리스트

  • 코드가 정상적으로 동작함
  • 테스트 코드 통과함
  • 문서(README 등)를 최신화함
  • 코드 스타일 가이드 준수

💬 기타 참고 사항

Summary by CodeRabbit

릴리스 노트

  • 새 기능

    • 협업 문서에 대한 관리자 권한 검증 추가
  • 개선 사항

    • WebSocket 인증 방식 개선
    • 토큰 기반 사용자 인증 강화

@stoneTiger0912 stoneTiger0912 self-assigned this Apr 2, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

Caution

Review failed

Pull request was closed or merged during review

워크스루

WebSocket 인증을 gRPC 기반 토큰 검증으로 변경하고, 협업 게이트웨이에 관리자 권한 검증을 추가했습니다. UserAuth 타입에서 역할과 토큰 버전을 제거하고 닉네임 필드를 도입했으며, proto 정의와 gRPC 클라이언트에 새로운 토큰 기반 사용자 조회 메서드를 추가했습니다.

변경 사항

통합 / 파일(s) 요약
gRPC 사용자 클라이언트 및 프로토
src/cardset/infrastructure/grpc/user-grpc.client.ts, src/proto/user.proto
토큰 기반 사용자 조회를 위한 getUserByToken() RPC 메서드 추가. proto 파일에 Java 코드 생성 옵션 및 두 개의 새로운 RPC 정의(GetUserByEmail, GetUserByToken) 추가.
인증 모듈 및 서비스
src/auth/auth.module.ts, src/auth/domain/auth.service.ts
AuthModuleGrpcClientModuleUserGrpcClient 추가. AuthService.verify()에서 JWT 페이로드에서 user_id만 추출하도록 변경, roletokenVersion 제거.
WebSocket 인증 가드
src/auth/infrastructure/guard/ws-auth.guard.ts
AuthService.verify() 호출을 UserGrpcClient.getUserByToken() 비동기 호출로 변경. 반환 타입을 boolean에서 Promise<boolean>으로 변경. 하드코딩된 테스트 사용자 주입 및 환경 기반 우회 제거.
협업 사용 사례 및 모듈
src/collaboration/application/collaboration.use-case.ts, src/collaboration/collaboration.module.ts
CollaborationUseCaseCardsetManagerOrmEntity 저장소 의존성 추가 및 isManager() 메서드 구현. CollaborationModuleCardsetManagerOrmEntity 등록, GrpcClientModule 임포트, UserGrpcClient 추가.
협업 게이트웨이
src/collaboration/infrastructure/gateway/collaboration.gateway.ts
join-cardset 이벤트에서 isManager() 호출을 통한 관리자 권한 검증 추가. 권한 없을 경우 조인 방지 및 오류 이벤트 발송.
사용자 인증 타입
src/shared/types/user-auth.type.ts
UserAuth 인터페이스에서 roletokenVersion 필드 제거, nickname 필드 추가.

시퀀스 다이어그램

sequenceDiagram
    participant Client
    participant Gateway as Collaboration Gateway
    participant UseCase as CollaborationUseCase
    participant GrpcClient as UserGrpcClient
    participant Repo as CardsetManager Repo

    Client->>Gateway: join-cardset 이벤트 (cardsetId, token)
    activate Gateway
    
    Gateway->>UseCase: isManager(cardsetId, userId)
    activate UseCase
    
    UseCase->>Repo: findOne({cardSetId, userId})
    activate Repo
    Repo-->>UseCase: 관리자 레코드 또는 null
    deactivate Repo
    
    UseCase-->>Gateway: boolean (true/false)
    deactivate UseCase
    
    alt 관리자 확인
        Gateway->>Client: 협업 문서 동기화 계속
    else 관리자 아님
        Gateway->>Gateway: 경고 로그
        Gateway->>Client: error 이벤트 (권한 없음)
        Gateway-->>Client: 조인 실패
    end
    
    deactivate Gateway
Loading

예상 코드 리뷰 노력

🎯 4 (복잡함) | ⏱️ ~50분

관련 가능성이 있는 PR

  • Fix: 동기화 수정 #3: 동일한 협업 관련 클래스 수정 - 주 PR에서는 CollaborationUseCaseisManager와 저장소 의존성을 추가하고, CollaborationGateway에 join-cardset 관리자 검증을 추가하며, 검색된 PR은 leave-cardset 비동기 처리와 debounce 맵 추가를 포함합니다.

🐰 토큰으로 사용자를 확인하고,
관리자만 편집 권한을 얻으니,
보안의 벽이 더욱 튼튼해졌네요! ✨
협업도 안전하게, 함께 작업해봅시다! 🎨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목은 협업 인증 추가라는 주요 변경사항을 명확하게 요약하며, 변경 사항의 핵심을 정확하게 반영하고 있습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/add-collab-auth

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@stoneTiger0912 stoneTiger0912 merged commit 7c1343a into main Apr 2, 2026
1 of 2 checks passed
@stoneTiger0912 stoneTiger0912 deleted the refactor/add-collab-auth branch April 2, 2026 04:37
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