Production

This commit is contained in:
Shubhankar45
2026-09-22 06:23:46 +00:00
commit 8fdd20b29f
217 changed files with 31212 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
"""Server-side refresh tokens.
Stored server-side (not stateless) precisely so they can be REVOKED — a departing MR
must lose access immediately (SEC-5).
"""
import uuid
from datetime import datetime
from sqlalchemy import Boolean, DateTime, ForeignKey, String
from sqlalchemy.dialects.postgresql import UUID as PGUUID
from sqlalchemy.orm import Mapped, mapped_column
from app.database.base import Base, TimestampMixin, UUIDMixin
class RefreshToken(Base, UUIDMixin, TimestampMixin):
__tablename__ = "refresh_token"
user_id: Mapped[uuid.UUID] = mapped_column(
PGUUID(as_uuid=True), ForeignKey("user.id", ondelete="CASCADE"), nullable=False, index=True
)
#: SHA-256 of the token — a database leak must not yield usable tokens.
token_hash: Mapped[str] = mapped_column(String(64), nullable=False, unique=True, index=True)
expires_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
revoked: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)