File size: 1,957 Bytes
d3e7277
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64f7965
 
 
 
 
 
 
ef8e0a7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93ff956
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
ALLOWED_MIME_TYPES = {
    "image/jpeg",
    "image/jpg",
    "image/png",
    "image/webp",
    "image/gif",
    "image/avif",
    "image/svg+xml",
}

MAX_FILE_SIZE_BYTES = 6 * 1024 * 1024  # 6 MB

AVATAR_BUCKET = "avatars"

PLACEHOLDER_DOMAINS = ["@placeholder.ai", "@studymate.ai"]

# Rate limits per email action (3 emails per hour)
EMAIL_RATE_LIMITS = {
    "email_verification": {"limit": 3, "window_seconds": 3600},
    "forgot_password": {"limit": 3, "window_seconds": 3600},
    "change_password_confirmation": {"limit": 3, "window_seconds": 3600},
}

# ── JWT / Access token ────────────────────────────────────────────────────────

# Short-lived JWT lifetime. Stateless: verified via signature only, no DB lookup.
ACCESS_TOKEN_EXPIRE_MINUTES = 15

# ── Refresh token ─────────────────────────────────────────────────────────────

# Long-lived opaque token lifetime. Stateful: looked up in the DB on every use.
REFRESH_TOKEN_EXPIRE_DAYS = 30

# ── HttpOnly cookie settings ──────────────────────────────────────────────────

REFRESH_COOKIE_NAME    = "refresh_token"
# Scope the cookie to the auth sub-path so it is NOT sent to /api/materials etc.
REFRESH_COOKIE_PATH    = "/api/auth"
REFRESH_COOKIE_MAX_AGE = REFRESH_TOKEN_EXPIRE_DAYS * 24 * 3600  # seconds

# ── Redis Auth Keys & TTLs ─────────────────────────────────────────────────────
REFRESH_TOKEN_KEY_PREFIX = "rt:"
USER_REFRESH_TOKENS_KEY_PREFIX = "user_rts:"
REFRESH_TOKEN_REDIS_TTL = REFRESH_TOKEN_EXPIRE_DAYS * 86400  # seconds