Skip to content

feat(python): UserInfoProvider 프로토콜로 사용자 정보 조회 통합#39

Merged
ywkim merged 11 commits into
mainfrom
refactor/user-info-provider
Dec 27, 2025
Merged

feat(python): UserInfoProvider 프로토콜로 사용자 정보 조회 통합#39
ywkim merged 11 commits into
mainfrom
refactor/user-info-provider

Conversation

@ywkim

@ywkim ywkim commented Dec 27, 2025

Copy link
Copy Markdown
Contributor

Summary

사용자 정보 조회 인터페이스를 UserRoleProvider에서 UserInfoProvider로 재설계하여 타입 안전성과 명확성을 향상시켰습니다.

Changes

  • UserInfo Pydantic 모델 추가

    • user_id: 고유 식별자
    • username: 계정명 (Sentry, 로깅, JWT용)
    • nickname: 표시명 (UI, LLM, LiveKit용, 선택)
    • email: 이메일 주소 (선택)
    • role: 사용자 역할
  • UserInfoProvider 프로토콜 설계

    • get_user_role() + get_user_context()get_user_info() 단일 메서드로 통합
    • 반환 타입: dictUserInfo (타입 안전성 향상)
  • BaseCrudRouter 업데이트

    • 새 UserInfoProvider 프로토콜 적용
    • Sentry 컨텍스트를 UserInfo에서 자동 생성
  • 테스트 업데이트

    • MockUserInfoProvider로 전환
    • 모든 기존 테스트 통과 확인

Testing

  • `poetry run make type-check` (Python) - 통과
  • `poetry run make lint` (Python) - 10.00/10 통과
  • `poetry run make test` (Python) - 23 tests 통과

Breaking Changes

Consumer 프로젝트에서 UserInfoProvider 구현 업데이트 필요:

  • `get_user_info(user_id, db) -> UserInfo` 단일 메서드 구현
  • `user_id`, `username` (필수), `nickname`, `email` (선택) 제공

Related Issues

Closes #[task_id]


ywkim and others added 9 commits December 27, 2025 22:58
OIDC UserInfo 표준 기반 타입 안전 사용자 정보 모델 추가:
- sub: 고유 식별자
- email, name: 선택 필드
- role: UserRole enum

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
BREAKING CHANGE: UserRoleProvider 프로토콜을 UserInfoProvider로 재설계
- get_user_role() + get_user_context() → get_user_info() 단일 메서드로 통합
- 타입 안전성: dict 반환 대신 UserInfo Pydantic 모델 반환
- 명확한 목적: 사용자 정보 조회 및 인증/모니터링 통합

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
BREAKING CHANGE: UserInfoProvider 프로토콜로 전환
- get_user_info() 단일 메서드로 사용자 정보 조회
- Sentry 컨텍스트를 UserInfo 모델에서 생성
- 타입 안전성 향상 (dict 대신 Pydantic 모델)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
UserInfoProvider 프로토콜에 맞춰 테스트 Mock 객체 변경:
- get_user_info() 메서드로 UserInfo 반환
- 타입 안전성 확보

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
docstring에서 Returns 섹션 제거 (타입 어노테이션으로 충분)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
BREAKING CHANGE: OIDC 표준 대신 Buppy 도메인에 충실하게 변경
- sub → user_id (명확한 네이밍)
- name → username (계정명, Sentry/로깅/JWT용) + nickname (표시명, UI/LLM/LiveKit용)
- username 필수 필드로 변경

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
user_id, username 필드 사용 (sub, name 대신)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
user_id, username, nickname 필드 사용

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
오픈소스 프로젝트이므로 범용적인 설명으로 변경

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

이 PR은 사용자 정보 조회 로직을 UserRoleProvider에서 UserInfoProvider 프로토콜로 리팩토링하여 타입 안정성과 코드 명확성을 크게 향상시켰습니다. get_user_role()get_user_context()get_user_info() 단일 메서드로 통합하고, 반환 타입을 Pydantic 모델인 UserInfo로 변경한 것은 훌륭한 설계 개선입니다. 관련하여 BaseCrudRouter와 테스트 코드도 새 프로토콜에 맞게 잘 업데이트되었습니다.

전반적으로 매우 좋은 변경이며, 코드 품질을 높이는 데 기여할 것입니다. 테스트 코드의 가독성과 유지보수성을 조금 더 향상시킬 수 있는 제안을 한 가지 남겼습니다. MockUserInfoProvider의 구현을 DRY 원칙에 더 부합하도록 개선하는 내용입니다.

Comment thread python/tests/unit/test_base_crud_router.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

이 PR은 사용자 정보 조회 인터페이스를 UserRoleProvider에서 UserInfoProvider로 재설계하여 타입 안전성과 코드 명확성을 향상시킵니다.

  • UserInfo Pydantic 모델 추가로 타입 안전한 사용자 정보 구조 제공
  • 두 개의 메서드(get_user_role, get_user_context)를 하나의 get_user_info 메서드로 통합하여 API 단순화
  • Sentry 컨텍스트 설정 로직을 UserInfo 모델에서 자동 생성하도록 개선

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
python/aioia_core/auth.py UserInfo Pydantic 모델과 UserInfoProvider 프로토콜 추가 (기존 UserRoleProvider 대체)
python/aioia_core/fastapi/base_crud_router.py 새로운 UserInfoProvider 프로토콜 적용 및 Sentry 컨텍스트 생성 로직 업데이트
python/tests/unit/test_base_crud_router.py MockUserInfoProvider로 테스트 업데이트 및 새로운 인터페이스에 맞춰 구현 수정
Comments suppressed due to low confidence (1)

python/aioia_core/auth.py:56

  • get_user_info 메서드의 docstring에 Returns 섹션이 누락되어 있습니다. Protocol 메서드는 명확한 API 계약을 제공해야 하므로, 반환값에 대한 설명을 추가하는 것이 좋습니다. 예를 들어 "UserInfo 객체를 반환하며, 사용자를 찾을 수 없는 경우 None을 반환합니다"와 같은 설명이 필요합니다.
    def get_user_info(  # pylint: disable=unnecessary-ellipsis
        self, user_id: str, db: Session
    ) -> UserInfo | None:
        """
        Get user information including role and metadata.

        Args:
            user_id: User identifier
            db: Database session
        """

Comment thread python/aioia_core/fastapi/base_crud_router.py Outdated
ywkim and others added 2 commits December 27, 2025 23:32
사용자 정보 딕셔너리로 관리하여 코드 중복 제거
- 테스트 사용자 추가 시 확장성 향상
- 명확성 유지

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
불필요한 필터링 제거
- user_id, username은 필수 필드 (str)
- email만 선택 필드이므로 조건부 추가
- 명확성 향상

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@ywkim ywkim merged commit 1601358 into main Dec 27, 2025
2 checks passed
@ywkim ywkim deleted the refactor/user-info-provider branch December 27, 2025 15:31
@github-actions

github-actions Bot commented Feb 4, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants