Files
site11/services/users/backend/models.py
jungwoo choi 1467766f3d Step 8: OAuth 2.0 인증 시스템 및 프로필 기능 구현
- OAuth 2.0 서비스 구현
  * Authorization Code, Client Credentials, Refresh Token 플로우 지원
  * 애플리케이션 등록 및 관리 기능
  * 토큰 introspection 및 revocation
  * SSO 설정 지원 (Google, GitHub, SAML)
  * 실용적인 스코프 시스템 (user, app, org, api 관리)

- 사용자 프로필 기능 확장
  * 프로필 사진 및 썸네일 필드 추가
  * bio, location, website 등 추가 프로필 정보
  * 이메일 인증 및 계정 활성화 상태 관리
  * UserPublicResponse 모델 추가

- OAuth 스코프 관리
  * picture 스코프 추가 (프로필 사진 접근 제어)
  * 카테고리별 스코프 정리 (기본 인증, 사용자 데이터, 앱 관리, 조직, API)
  * 스코프별 승인 필요 여부 설정

- 인프라 개선
  * Users 서비스 포트 매핑 추가 (8001)
  * OAuth 서비스 Docker 구성 (포트 8003)
  * Kafka 이벤트 통합 (USER_CREATED, USER_UPDATED, USER_DELETED)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-10 17:37:16 +09:00

31 lines
1.2 KiB
Python

from beanie import Document
from pydantic import EmailStr, Field, HttpUrl
from datetime import datetime
from typing import Optional
class User(Document):
username: str = Field(..., unique=True)
email: EmailStr
full_name: Optional[str] = None
profile_picture: Optional[str] = Field(None, description="프로필 사진 URL")
profile_picture_thumbnail: Optional[str] = Field(None, description="프로필 사진 썸네일 URL")
bio: Optional[str] = Field(None, max_length=500, description="자기소개")
location: Optional[str] = Field(None, description="위치")
website: Optional[str] = Field(None, description="개인 웹사이트")
is_email_verified: bool = Field(default=False, description="이메일 인증 여부")
is_active: bool = Field(default=True, description="계정 활성화 상태")
created_at: datetime = Field(default_factory=datetime.now)
updated_at: datetime = Field(default_factory=datetime.now)
class Settings:
collection = "users"
class Config:
json_schema_extra = {
"example": {
"username": "john_doe",
"email": "john@example.com",
"full_name": "John Doe"
}
}