fix(auth): atomic refresh rotation and a 7-day absolute session limit
- Rotation claims the old token with a conditional update; of two concurrent refreshes only one gets a successor, so a stolen token cannot fork into two live sessions. - A token rotated out less than 10 s ago (parallel tab) is refused without revoking every session; later reuse still revokes them all. - Sessions end at most SESSION_MAX_AGE (default 7 days) after login: the login time is inherited by every rotated token and caps its expiry. - The refresh cookie is cleared with the same attributes it was set with. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
5c666fe49a
commit
2de93bc087
6 files changed
+125
-19
No files matched your search
@@ -161,6 +161,9 @@ model RefreshToken {
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
revokedAt DateTime?
|
||||
// Anmeldezeitpunkt der Sitzung, an jede rotierte Nachfolge-Token vererbt:
|
||||
// spaetestens SESSION_MAX_AGE danach ist neu anzumelden.
|
||||
sessionStartedAt DateTime @default(now())
|
||||
|
||||
@@index([userId])
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user