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>
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
"""Authentication history model definitions"""
|
|
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field, ConfigDict
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
from bson import ObjectId
|
|
|
|
|
|
class AuthAction(str, Enum):
|
|
"""Authentication action types"""
|
|
LOGIN = "login"
|
|
LOGOUT = "logout"
|
|
TOKEN_REFRESH = "token_refresh"
|
|
AUTHORIZATION_CODE = "authorization_code"
|
|
PASSWORD_RESET = "password_reset"
|
|
REGISTER = "register"
|
|
FAILED_LOGIN = "failed_login"
|
|
|
|
|
|
class AuthHistoryBase(BaseModel):
|
|
"""Base authentication history model"""
|
|
user_id: str
|
|
application_id: Optional[str] = None
|
|
action: AuthAction
|
|
ip_address: str
|
|
user_agent: Optional[str] = None
|
|
result: str = "success"
|
|
details: Optional[dict] = None
|
|
|
|
model_config = ConfigDict(use_enum_values=True)
|
|
|
|
|
|
class AuthHistoryCreate(AuthHistoryBase):
|
|
"""Authentication history creation model"""
|
|
pass
|
|
|
|
|
|
class AuthHistory(AuthHistoryBase):
|
|
"""Authentication history response model"""
|
|
id: str = Field(alias="_id")
|
|
created_at: datetime
|
|
|
|
model_config = ConfigDict(
|
|
populate_by_name=True,
|
|
arbitrary_types_allowed=True,
|
|
json_encoders={ObjectId: str}
|
|
)
|
|
|
|
|
|
class AuthHistoryInDB(AuthHistory):
|
|
"""Authentication history model in database"""
|
|
pass |