feat(auth): sessions expire server-side; password change and reset end other sessions (M462 #4978)
Sessions had no server-side expiry: only the web cookie's 30-day Max-Age limited them, and a bearer token (Android) lived until revoked by hand. GetSessionByTokenHash and ListSessionsForUser now ignore sessions idle for 30 days or older than a year, and the GC worker deletes them hourly. A password change was a plain UPDATE, so a session opened with the old password survived it. Now: - self-service change signs out every other device and keeps this one; - reset by email ends every session the account has; - an admin reset ends the target's sessions (keeping the admin's own when they reset themselves). The success copy on web and Android says the other devices were signed out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -68,3 +68,10 @@ UPDATE system_playlist_runs
|
||||
DELETE FROM password_resets
|
||||
WHERE (used_at IS NOT NULL AND used_at < now() - INTERVAL '7 days')
|
||||
OR (used_at IS NULL AND expires_at < now() - INTERVAL '1 hour');
|
||||
|
||||
-- name: GcDeleteExpiredSessions :execrows
|
||||
-- Sessions past their idle (30 days) or absolute (1 year) limit. They already
|
||||
-- fail auth through GetSessionByTokenHash's filter; this only clears the rows.
|
||||
DELETE FROM sessions
|
||||
WHERE last_seen_at <= now() - interval '30 days'
|
||||
OR created_at <= now() - interval '365 days';
|
||||
|
||||
Reference in New Issue
Block a user