Skip to content

Instantly share code, notes, and snippets.

View sashapenkin12's full-sized avatar

Aleksandr Penkin sashapenkin12

  • Kyrgyzstan, Bishkek
  • 14:41 (UTC +06:00)
View GitHub Profile
@rochacbruno
rochacbruno / fastapi_session.py
Last active March 26, 2025 00:32
Session based cookie auth fastapi
from fastapi import Request, Depends, HTTPException, Response
from fastapi.responses import RedirectResponse
# This must be randomly generated
RANDON_SESSION_ID = "iskksioskassyidd"
# This must be a lookup on user database
USER_CORRECT = ("admin", "admin")
# This must be Redis, Memcached, SQLite, KV, etc...