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>
This commit is contained in:
@ -24,20 +24,50 @@ class UserCreate(BaseModel):
|
||||
username: str
|
||||
email: str
|
||||
full_name: Optional[str] = None
|
||||
profile_picture: Optional[str] = None
|
||||
bio: Optional[str] = None
|
||||
location: Optional[str] = None
|
||||
website: Optional[str] = None
|
||||
|
||||
class UserUpdate(BaseModel):
|
||||
username: Optional[str] = None
|
||||
email: Optional[str] = None
|
||||
full_name: Optional[str] = None
|
||||
profile_picture: Optional[str] = None
|
||||
profile_picture_thumbnail: Optional[str] = None
|
||||
bio: Optional[str] = None
|
||||
location: Optional[str] = None
|
||||
website: Optional[str] = None
|
||||
is_email_verified: Optional[bool] = None
|
||||
is_active: Optional[bool] = None
|
||||
|
||||
class UserResponse(BaseModel):
|
||||
id: str
|
||||
username: str
|
||||
email: str
|
||||
full_name: Optional[str] = None
|
||||
profile_picture: Optional[str] = None
|
||||
profile_picture_thumbnail: Optional[str] = None
|
||||
bio: Optional[str] = None
|
||||
location: Optional[str] = None
|
||||
website: Optional[str] = None
|
||||
is_email_verified: bool
|
||||
is_active: bool
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class UserPublicResponse(BaseModel):
|
||||
"""공개 프로필용 응답 (민감한 정보 제외)"""
|
||||
id: str
|
||||
username: str
|
||||
full_name: Optional[str] = None
|
||||
profile_picture: Optional[str] = None
|
||||
profile_picture_thumbnail: Optional[str] = None
|
||||
bio: Optional[str] = None
|
||||
location: Optional[str] = None
|
||||
website: Optional[str] = None
|
||||
created_at: datetime
|
||||
|
||||
|
||||
# Global Kafka producer
|
||||
kafka_producer: Optional[KafkaProducer] = None
|
||||
@ -101,6 +131,13 @@ async def get_users():
|
||||
username=user.username,
|
||||
email=user.email,
|
||||
full_name=user.full_name,
|
||||
profile_picture=user.profile_picture,
|
||||
profile_picture_thumbnail=user.profile_picture_thumbnail,
|
||||
bio=user.bio,
|
||||
location=user.location,
|
||||
website=user.website,
|
||||
is_email_verified=user.is_email_verified,
|
||||
is_active=user.is_active,
|
||||
created_at=user.created_at,
|
||||
updated_at=user.updated_at
|
||||
) for user in users]
|
||||
@ -116,6 +153,13 @@ async def get_user(user_id: str):
|
||||
username=user.username,
|
||||
email=user.email,
|
||||
full_name=user.full_name,
|
||||
profile_picture=user.profile_picture,
|
||||
profile_picture_thumbnail=user.profile_picture_thumbnail,
|
||||
bio=user.bio,
|
||||
location=user.location,
|
||||
website=user.website,
|
||||
is_email_verified=user.is_email_verified,
|
||||
is_active=user.is_active,
|
||||
created_at=user.created_at,
|
||||
updated_at=user.updated_at
|
||||
)
|
||||
@ -133,7 +177,11 @@ async def create_user(user_data: UserCreate):
|
||||
user = User(
|
||||
username=user_data.username,
|
||||
email=user_data.email,
|
||||
full_name=user_data.full_name
|
||||
full_name=user_data.full_name,
|
||||
profile_picture=user_data.profile_picture,
|
||||
bio=user_data.bio,
|
||||
location=user_data.location,
|
||||
website=user_data.website
|
||||
)
|
||||
|
||||
await user.create()
|
||||
@ -157,6 +205,13 @@ async def create_user(user_data: UserCreate):
|
||||
username=user.username,
|
||||
email=user.email,
|
||||
full_name=user.full_name,
|
||||
profile_picture=user.profile_picture,
|
||||
profile_picture_thumbnail=user.profile_picture_thumbnail,
|
||||
bio=user.bio,
|
||||
location=user.location,
|
||||
website=user.website,
|
||||
is_email_verified=user.is_email_verified,
|
||||
is_active=user.is_active,
|
||||
created_at=user.created_at,
|
||||
updated_at=user.updated_at
|
||||
)
|
||||
@ -186,6 +241,27 @@ async def update_user(user_id: str, user_update: UserUpdate):
|
||||
if user_update.full_name is not None:
|
||||
user.full_name = user_update.full_name
|
||||
|
||||
if user_update.profile_picture is not None:
|
||||
user.profile_picture = user_update.profile_picture
|
||||
|
||||
if user_update.profile_picture_thumbnail is not None:
|
||||
user.profile_picture_thumbnail = user_update.profile_picture_thumbnail
|
||||
|
||||
if user_update.bio is not None:
|
||||
user.bio = user_update.bio
|
||||
|
||||
if user_update.location is not None:
|
||||
user.location = user_update.location
|
||||
|
||||
if user_update.website is not None:
|
||||
user.website = user_update.website
|
||||
|
||||
if user_update.is_email_verified is not None:
|
||||
user.is_email_verified = user_update.is_email_verified
|
||||
|
||||
if user_update.is_active is not None:
|
||||
user.is_active = user_update.is_active
|
||||
|
||||
user.updated_at = datetime.now()
|
||||
await user.save()
|
||||
|
||||
@ -209,6 +285,13 @@ async def update_user(user_id: str, user_update: UserUpdate):
|
||||
username=user.username,
|
||||
email=user.email,
|
||||
full_name=user.full_name,
|
||||
profile_picture=user.profile_picture,
|
||||
profile_picture_thumbnail=user.profile_picture_thumbnail,
|
||||
bio=user.bio,
|
||||
location=user.location,
|
||||
website=user.website,
|
||||
is_email_verified=user.is_email_verified,
|
||||
is_active=user.is_active,
|
||||
created_at=user.created_at,
|
||||
updated_at=user.updated_at
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user