Token Revocation & Multi-Instance Sync (LMDB + Redis)
This page explains how ProxyAuth tracks revoked tokens, why there are two different storage backends involved, and — critically — what you need for revocation to actually propagate across a multi-instance deployment.
The three tiers
A revoked token's state can live in up to three places at once:
| Tier | Scope | Persists across restart? | Role |
|---|---|---|---|
In-memory (RevokedTokenMap, a DashMap) |
This process only | No | Hot path — checked on every token validation. |
LMDB (local disk, /opt/proxyauth/db/ by default) |
This instance only | Yes | Local durable store; reloaded into memory on startup. |
| Redis (optional) | Shared across every instance pointed at it | Yes (Redis's own persistence) | Cross-instance sync relay — not the primary store. |
Every token validation only ever checks the in-memory map — LMDB and Redis exist purely to keep that in-memory map correct across restarts and across instances.
Single instance (no Redis)
If redis isn't set in config.json, this is the whole picture:
flowchart TD
A(["POST /adm/revoke"]) --> B[("RAM — DashMap")]
B --> C["Answers every validation from now on"]
A --> D[("LMDB — disk")]
D --> E["Reloaded into RAM on next restart"]
classDef edge fill:#eef2ff,stroke:#4f46e5,stroke-width:1px,color:#1e1b4b
classDef store fill:#fef3c7,stroke:#d97706,stroke-width:1px,color:#78350f
classDef step fill:#f8fafc,stroke:#64748b,stroke-width:1px,color:#0f172a
class A edge
class B,D store
class C,E step
This is enough for a single instance, or for a cluster where you're fine calling /adm/revoke on each instance individually. It is not enough for automatic cross-instance propagation — a revocation issued to instance A never reaches instance B without Redis.
Multi-instance (with Redis)
If redis is set to a Redis connection URL in config.json, every instance additionally participates in a sync loop that runs every 15 seconds:
flowchart TD
A(["Instance A: POST /adm/revoke"]) --> B[("RAM — A's DashMap")]
B --> C[("Redis")]
C --> C1["token:<id> = <exp><br/><id>_action = 1 or 2 (revoke / un-revoke)<br/><id>_count incremented<br/>action keys expire after 300s"]
C1 -.->|"up to 15s later, on its own sync tick"| D["Every instance A, B, C..."]
D --> E["Scans Redis for *_action keys"]
E --> F["Applies each pending action<br/>to its own LMDB (disk) + RAM"]
F --> G["Re-syncs its RAM from its own LMDB<br/>belt-and-suspenders consistency"]
G --> H(["Purges anything expired<br/>from RAM + LMDB"])
classDef edge fill:#eef2ff,stroke:#4f46e5,stroke-width:1px,color:#1e1b4b
classDef store fill:#fef3c7,stroke:#d97706,stroke-width:1px,color:#78350f
classDef step fill:#f8fafc,stroke:#64748b,stroke-width:1px,color:#0f172a
classDef done fill:#dcfce7,stroke:#16a34a,stroke-width:1px,color:#14532d
class A edge
class B,C store
class C1,D,E,F,G step
class H done
Key points:
- Propagation is not instant. Expect up to ~15 seconds for a revocation made on one instance to take effect on the others. If you need immediate cross-instance revocation for an active incident, either wait it out (usually acceptable — 15s is a short window) or call
/adm/revokeagainst every instance directly instead of relying on sync. - Redis is a relay, not a database you query directly. ProxyAuth doesn't read
token:<id>values for validation — it only reads them once, during sync, to update its own local LMDB+RAM. If Redis is unavailable, sync simply doesn't run that tick (retried automatically); it doesn't affect the in-memory/LMDB state each instance already has. - Action keys expire after 5 minutes. This is a cleanup mechanism for the
*_actionmarker keys themselves, not for the underlying revocation — the revocation's own expiry (whatever you passed asexpto/adm/revoke, or "permanent" if omitted) is tracked separately in thetoken:<id>value and in each instance's LMDB/RAM. - Redis connection failures retry automatically at startup (3 attempts, 5s apart) and the sync loop reconnects on subsequent ticks if a connection attempt fails mid-run — a temporary Redis outage doesn't crash the service, it just pauses cross-instance sync until Redis is reachable again.
Configuration
{
"redis": "redis://user:password@redis-host:6379/0"
}
See the config.json Reference — redis accepts any standard Redis connection URL, or omit/set to null to run in local-only (LMDB) mode.
LMDB's storage path is not a config.json option — it's controlled by the LMDB_PATH environment variable (defaults to /opt/proxyauth/db/). This directory is created and permissioned for you by proxyauth prepare (see the Installation Guide).
Operational notes
- LMDB is always active, with or without Redis — it's the durability layer that survives a restart even in single-instance setups.
- A revoked-token entry with
exp: 0(or omitted) is permanent — it's never purged by the periodic expiry cleanup, and stays revoked indefinitely. Only entries with a non-zero, pastexpget purged from RAM/LMDB automatically. - Purge runs on the same 15-second tick as the Redis sync loop (or on process shutdown, when LMDB is flushed to disk via
env.sync(true)), so cleanup of long-expired revocations happens automatically without a separate cron job. - This sync loop only starts if
redisis configured. In local-only mode, there's no periodic background task beyond the initial LMDB load at startup — revocations you make are immediately effective locally and durable on disk, they just don't reach other instances.
See also
- Admin Routes Reference — the
POST /adm/revokeendpoint that triggers all of this. - config.json Reference — the
redisfield. - Installation Guide —
proxyauth prepare, which sets up/opt/proxyauth/db.
📖 Wiki Home · 💻 Source Code · 🐛 Report an Issue · 📜 License
Found an error or something outdated on this page? Open an issue or submit a PR against the wiki repository.