Keeping sessions in Redis
~3 minBy default the module encrypts the whole session, tokens included, into the session cookie. Name a Nitro storage mount in `thunderid.storage` to keep sessions there instead. The cookie then carries only a sealed reference to the session, and every instance that shares the mount shares the sessions. The `/api/auth/token` route still returns the access token to a signed-in browser.
Keep sessions in Redis
Point a Nitro storage mount at Redis
The mount uses unstorage's Redis driver, so the module needs no Redis client of its own. Any other unstorage driver works the same way.export default defineNuxtConfig({modules: ['@thunderid/nuxt'],nitro: {storage: {sessions: { driver: 'redis', url: process.env.REDIS_URL },},},thunderid: {storage: 'sessions',},})
Enable back-channel logout, if you use it
Logouts are recorded in the same mount, so they reach every instance. Name another mount in
backchannelLogout.store only to record them somewhere else.thunderid: {storage: 'sessions',backchannelLogout: { enabled: true },}
Check it works
Sign in, then list the sessions. One key appears per signed-in session, named thunderid:0:<client id>:session:<session id>. Deleting it signs that session out on every instance.
redis-cli -u "$REDIS_URL" --scan --pattern 'thunderid:*:*:session:*'redis-cli -u "$REDIS_URL" DEL <key>
How sessions behave with storage
Split the storage by kind of data
`storage` also takes a mount for each kind of data, such as `{ session: 'sessions', sessionState: 'sign-ins' }`. A kind left out goes to `session`. Without `session`, sessions stay in the cookie and the kinds left out stay in the memory of the process, so include `session` to share sessions between instances.