FastAPI + Celery + Next.js + Postgres/Redis app with company monitoring, source collection, LLM-based change analysis, enrichment, and account security (Turnstile, escalating lockout, email verification).
22 lines
765 B
Python
22 lines
765 B
Python
"""Global per-IP bans. Deliberately separate from IpThrottleState - once any
|
|
action type escalates an IP to permanent, that IP is blocked from every
|
|
sensitive endpoint (register/login/resend/reset), not just the one action
|
|
that triggered it."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, String
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.db.base import Base, TimestampMixin, UUIDPrimaryKeyMixin
|
|
|
|
|
|
class IpBan(Base, UUIDPrimaryKeyMixin, TimestampMixin):
|
|
__tablename__ = "ip_bans"
|
|
|
|
ip_address: Mapped[str] = mapped_column(String(45), unique=True, index=True)
|
|
banned_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
reason: Mapped[str] = mapped_column(String(255))
|