Fix: reject revoked tokens on all replicas when Redis writes fail

This commit is contained in:
2026-10-23 22:33:12 +03:00
parent af184cabe3
commit 4abbe84847
42 changed files with 876 additions and 501 deletions
+53
View File
@@ -0,0 +1,53 @@
# 2026-10-23T18:55Z scripts/revocation-pause.sh against the compose stack (2 replicas behind HAProxy)
# replica ids: ef8f943d313b 33ea33bfe1fd
$ PAUSE_MS=5000 scripts/revocation-pause.sh
send message with Idempotency-Key: 201 33ea33bfe1fd
warm the session on both replicas:
GET /users/me -> 200 ef8f943d313b
GET /users/me -> 200 33ea33bfe1fd
GET /users/me -> 200 ef8f943d313b
GET /users/me -> 200 33ea33bfe1fd
redis: CLIENT PAUSE 5000 WRITE -> OK
DELETE /auth/sessions/current -> 204 ef8f943d313b after 5.1 s
old token after logout (redis writes still paused: no):
GET /users/me -> 401 33ea33bfe1fd
GET /users/me -> 401 ef8f943d313b
GET /users/me -> 401 33ea33bfe1fd
GET /users/me -> 401 ef8f943d313b
POST message, same key -> 401 33ea33bfe1fd
POST message, same key -> 401 ef8f943d313b
after the pause: session key in redis = revoked
GET /users/me -> 401 33ea33bfe1fd
GET /users/me -> 401 ef8f943d313b
$ PAUSE_MS=12000 scripts/revocation-pause.sh
send message with Idempotency-Key: 201 33ea33bfe1fd
warm the session on both replicas:
GET /users/me -> 200 ef8f943d313b
GET /users/me -> 200 33ea33bfe1fd
GET /users/me -> 200 ef8f943d313b
GET /users/me -> 200 33ea33bfe1fd
redis: CLIENT PAUSE 12000 WRITE -> OK
DELETE /auth/sessions/current -> 503 ef8f943d313b after 8.63 s
old token after logout (redis writes still paused: yes):
GET /users/me -> 401 33ea33bfe1fd
GET /users/me -> 401 ef8f943d313b
GET /users/me -> 401 33ea33bfe1fd
GET /users/me -> 401 ef8f943d313b
POST message, same key -> 401 33ea33bfe1fd
POST message, same key -> 401 ef8f943d313b
after the pause: session key in redis = revoked
GET /users/me -> 401 33ea33bfe1fd
GET /users/me -> 401 ef8f943d313b
# API log: pending revocation seen by the replicas
api-1 2026-10-23T18:55:37.498Z Pending session revocations found, cached sessions are not trusted until they are written
api-1 2026-10-23T18:55:42.419Z Wrote 1 pending session revocations to the cache
api-1 2026-10-23T18:55:45.442Z Pending session revocations found, cached sessions are not trusted until they are written
api-1 2026-10-23T18:55:57.192Z Wrote 1 pending session revocations to the cache
api-2 2026-10-23T18:55:23.552Z Pending session revocations found, cached sessions are not trusted until they are written
api-2 2026-10-23T18:55:37.425Z Pending session revocations found, cached sessions are not trusted until they are written
api-2 2026-10-23T18:55:42.420Z Wrote 1 pending session revocations to the cache
api-2 2026-10-23T18:55:45.442Z Pending session revocations found, cached sessions are not trusted until they are written
api-2 2026-10-23T18:55:57.193Z Wrote 1 pending session revocations to the cache