Backend: - Add 2FA authentication with TOTP support - Add API keys management system - Add audit logging for security events - Add file upload/management system - Add notifications system with preferences - Add session management - Add webhooks integration - Add analytics endpoints - Add export functionality - Add password policy enforcement - Add new database migrations for core tables Frontend: - Add module position system (top/bottom sidebar sections) - Add search and notifications module configuration tabs - Add mobile logo replacing hamburger menu - Center page title absolutely when no tabs present - Align sidebar footer toggles with navigation items - Add lighter icon color in dark theme for mobile - Add API keys management page - Add notifications page with context - Add admin analytics and audit logs pages 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
56 lines
1.4 KiB
Python
56 lines
1.4 KiB
Python
"""Pydantic schemas for API Key requests/responses."""
|
|
|
|
from datetime import datetime
|
|
from typing import Optional, List
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class APIKeyBase(BaseModel):
|
|
"""Base API key schema."""
|
|
name: str = Field(..., min_length=1, max_length=100)
|
|
scopes: Optional[List[str]] = None
|
|
expires_at: Optional[datetime] = None
|
|
|
|
|
|
class APIKeyCreate(APIKeyBase):
|
|
"""Schema for creating an API key."""
|
|
pass
|
|
|
|
|
|
class APIKeyUpdate(BaseModel):
|
|
"""Schema for updating an API key."""
|
|
name: Optional[str] = Field(None, min_length=1, max_length=100)
|
|
scopes: Optional[List[str]] = None
|
|
is_active: Optional[bool] = None
|
|
expires_at: Optional[datetime] = None
|
|
|
|
|
|
class APIKey(BaseModel):
|
|
"""Schema for API key response (without the actual key)."""
|
|
id: str
|
|
user_id: str
|
|
name: str
|
|
key_prefix: str
|
|
scopes: Optional[List[str]] = None
|
|
is_active: bool
|
|
last_used_at: Optional[datetime] = None
|
|
last_used_ip: Optional[str] = None
|
|
usage_count: int = 0
|
|
expires_at: Optional[datetime] = None
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class APIKeyWithSecret(APIKey):
|
|
"""Schema for API key response with the actual key (only on creation)."""
|
|
key: str # The actual API key - only shown once
|
|
|
|
|
|
class APIKeyList(BaseModel):
|
|
"""Schema for paginated API key list."""
|
|
items: List[APIKey]
|
|
total: int
|