feat: OAuth 2.0 백엔드 시스템 구현 완료
Phase 1 & 2 완료: - 프로젝트 기본 구조 설정 - Docker Compose 환경 구성 (MongoDB, Redis, Backend, Frontend) - FastAPI 기반 OAuth 2.0 백엔드 구현 주요 기능: - JWT 기반 인증 시스템 - 3단계 권한 체계 (System Admin/Group Admin/User) - 사용자 관리 CRUD API - 애플리케이션 관리 CRUD API - OAuth 2.0 Authorization Code Flow - Refresh Token 관리 - 인증 히스토리 추적 API 엔드포인트: - /auth/* - 인증 관련 (register, login, logout, refresh) - /users/* - 사용자 관리 - /applications/* - 애플리케이션 관리 - /oauth/* - OAuth 2.0 플로우 보안 기능: - bcrypt 비밀번호 해싱 - JWT 토큰 인증 - CORS 설정 - Rate limiting 준비 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
79
oauth/backend/app/models/application.py
Normal file
79
oauth/backend/app/models/application.py
Normal file
@ -0,0 +1,79 @@
|
||||
"""Application model definitions"""
|
||||
|
||||
from typing import List, Optional, Dict, Any
|
||||
from pydantic import BaseModel, Field, ConfigDict
|
||||
from datetime import datetime
|
||||
from bson import ObjectId
|
||||
|
||||
|
||||
class ApplicationTheme(BaseModel):
|
||||
"""Application theme configuration"""
|
||||
primary_color: str = "#1976d2"
|
||||
secondary_color: str = "#dc004e"
|
||||
logo_url: Optional[str] = None
|
||||
favicon_url: Optional[str] = None
|
||||
font_family: str = "Roboto, sans-serif"
|
||||
custom_css: Optional[str] = None
|
||||
|
||||
|
||||
class ApplicationBase(BaseModel):
|
||||
"""Base application model"""
|
||||
app_name: str = Field(..., min_length=3, max_length=100)
|
||||
description: Optional[str] = None
|
||||
redirect_uris: List[str] = []
|
||||
allowed_origins: List[str] = []
|
||||
theme: Optional[ApplicationTheme] = ApplicationTheme()
|
||||
permissions: List[str] = ["sso", "name", "email"] # Default permissions
|
||||
is_active: bool = True
|
||||
|
||||
|
||||
class ApplicationCreate(ApplicationBase):
|
||||
"""Application creation model"""
|
||||
pass
|
||||
|
||||
|
||||
class ApplicationUpdate(BaseModel):
|
||||
"""Application update model"""
|
||||
app_name: Optional[str] = Field(None, min_length=3, max_length=100)
|
||||
description: Optional[str] = None
|
||||
redirect_uris: Optional[List[str]] = None
|
||||
allowed_origins: Optional[List[str]] = None
|
||||
theme: Optional[ApplicationTheme] = None
|
||||
permissions: Optional[List[str]] = None
|
||||
is_active: Optional[bool] = None
|
||||
|
||||
|
||||
class Application(ApplicationBase):
|
||||
"""Application response model"""
|
||||
id: str = Field(alias="_id")
|
||||
client_id: str
|
||||
client_secret: str
|
||||
created_by: str
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
arbitrary_types_allowed=True,
|
||||
json_encoders={ObjectId: str}
|
||||
)
|
||||
|
||||
|
||||
class ApplicationInDB(Application):
|
||||
"""Application model in database"""
|
||||
pass
|
||||
|
||||
|
||||
class ApplicationPublic(BaseModel):
|
||||
"""Public application information (no secret)"""
|
||||
id: str = Field(alias="_id")
|
||||
app_name: str
|
||||
description: Optional[str] = None
|
||||
theme: Optional[ApplicationTheme] = None
|
||||
permissions: List[str] = []
|
||||
|
||||
model_config = ConfigDict(
|
||||
populate_by_name=True,
|
||||
arbitrary_types_allowed=True,
|
||||
json_encoders={ObjectId: str}
|
||||
)
|
||||
Reference in New Issue
Block a user