feat(auth): add session policy settings + account columns + migration
First commit in the session-expiration-policy series (see docs/plans/2026-05-13-session-expiration-policy.md). No behavior change yet — this lays the schema + settings groundwork only. - Settings: SESSION_IDLE_MINUTES_DEFAULT=4320 (3d), SESSION_ABSOLUTE_MINUTES_DEFAULT=20160 (14d), plus MIN/MAX bounds so account overrides have envelopes (15min..30d idle, 1h..90d absolute). - accounts table: nullable session_idle_minutes and session_absolute_minutes columns (NULL = use system default), plus a CHECK constraint that rejects idle > absolute when both are set. Partial-override validation lives at the app layer because the DB cannot read Settings. Subsequent commits will: distinguish idle vs invalid-token expiry on the wire, embed auth_time/idle_max/abs_max in refresh JWTs, enforce the absolute cap in /auth/refresh, add the owner-only policy + bulk-revoke endpoints, and surface everything in an AccountSecurity settings page with a session-expiry toast. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -69,6 +69,19 @@ class Settings(BaseSettings):
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES: int = 5
|
||||
REFRESH_TOKEN_EXPIRE_DAYS: int = 7
|
||||
|
||||
# Session policy — see docs/plans/2026-05-13-session-expiration-policy.md
|
||||
# Refresh tokens enforce two windows: idle (between rotations) and absolute
|
||||
# (from original login). Defaults can be overridden per-account, bounded by
|
||||
# the MIN/MAX values below. Values are minutes everywhere except inside the
|
||||
# refresh JWT, where idle_max/abs_max are stored as seconds for direct
|
||||
# Unix-time math.
|
||||
SESSION_IDLE_MINUTES_DEFAULT: int = 4320 # 3 days
|
||||
SESSION_ABSOLUTE_MINUTES_DEFAULT: int = 20160 # 14 days
|
||||
SESSION_IDLE_MINUTES_MIN: int = 15
|
||||
SESSION_IDLE_MINUTES_MAX: int = 43200 # 30 days
|
||||
SESSION_ABSOLUTE_MINUTES_MIN: int = 60 # 1 hour
|
||||
SESSION_ABSOLUTE_MINUTES_MAX: int = 129600 # 90 days
|
||||
|
||||
# Security
|
||||
BCRYPT_ROUNDS: int = 12
|
||||
|
||||
|
||||
Reference in New Issue
Block a user