Add complete NexaMFA push MFA system with: - FastAPI backend with PostgreSQL, Redis, OIDC provider, and Prometheus metrics - React TypeScript admin console - Android Kotlin/Jetpack Compose app with biometric authentication - Docker Compose deployment configuration - Gitea CI workflow for backend, frontend, and Android builds - Environment configuration template with security settings - Documentation for security model, deployment
25 lines
1.2 KiB
Python
25 lines
1.2 KiB
Python
from datetime import datetime
|
|
import uuid
|
|
|
|
from sqlalchemy import Boolean, DateTime, ForeignKey, String, func
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.core.database import Base
|
|
|
|
|
|
class AuthorizationCode(Base):
|
|
__tablename__ = "authorization_codes"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4)
|
|
code_hash: Mapped[str] = mapped_column(String(128), unique=True, index=True)
|
|
client_id: Mapped[str] = mapped_column(String(255), index=True)
|
|
redirect_uri: Mapped[str] = mapped_column(String(1024))
|
|
scope: Mapped[str] = mapped_column(String(1024), default="openid profile email")
|
|
state: Mapped[str | None] = mapped_column(String(1024), nullable=True)
|
|
nonce: Mapped[str | None] = mapped_column(String(1024), nullable=True)
|
|
user_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"), index=True)
|
|
challenge_id: Mapped[uuid.UUID] = mapped_column(ForeignKey("challenges.id", ondelete="CASCADE"), index=True)
|
|
expires_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), index=True)
|
|
used: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|