Self-hosted Docker Compose manager. - Backend: FastAPI + docker-py + SQLite (JWT auth, file-first stacks, lifecycle, live status, WebSocket logs, docker-run converter, audit log) - Frontend: React + Vite + Tailwind (login/setup, dashboard, stacks, stack detail, Monaco editor, dark/light theme) - Deployment: docker-compose.yml, Dockerfiles, nginx reverse proxy Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
51 lines
971 B
Python
51 lines
971 B
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime, timezone
|
|
from typing import Optional
|
|
|
|
from sqlmodel import Field, SQLModel
|
|
|
|
|
|
def _now() -> datetime:
|
|
return datetime.now(timezone.utc)
|
|
|
|
|
|
class User(SQLModel, table=True):
|
|
id: Optional[int] = Field(default=None, primary_key=True)
|
|
username: str = Field(index=True, unique=True)
|
|
hashed_password: str
|
|
role: str = Field(default="user") # "admin" | "user"
|
|
is_active: bool = Field(default=True)
|
|
created_at: datetime = Field(default_factory=_now)
|
|
|
|
|
|
# --- API schemas ---
|
|
|
|
|
|
class UserRead(SQLModel):
|
|
id: int
|
|
username: str
|
|
role: str
|
|
is_active: bool
|
|
|
|
|
|
class UserCreate(SQLModel):
|
|
username: str
|
|
password: str
|
|
role: str = "admin"
|
|
|
|
|
|
class LoginRequest(SQLModel):
|
|
username: str
|
|
password: str
|
|
|
|
|
|
class TokenPair(SQLModel):
|
|
access_token: str
|
|
refresh_token: str
|
|
token_type: str = "bearer"
|
|
|
|
|
|
class RefreshRequest(SQLModel):
|
|
refresh_token: str
|