Skip to content

fix(example): set Redis TTL on session keys using absoluteDuration - #54

Merged
nandan-bhat merged 6 commits into
mainfrom
fix/redis-store-ttl
Oct 8, 2026
Merged

nandan-bhat merged 6 commits into
mainfrom
fix/redis-store-ttl

Conversation

@frederikprijck

@frederikprijck frederikprijck commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

Summary

  • set() in the Redis store example had no EX option, so session keys persisted indefinitely even after the SDK considered them expired
  • Compute the remaining TTL as createdAt + absoluteDuration - now so keys expire at the correct wall-clock time regardless of how many times the session is written
  • Apply the same TTL to the logout:sid:<sid> index key
  • Thread absoluteDuration through createRedisSessionStore (defaulting to the SDK's own default of 3 days) so the Redis TTL stays in sync with sessionConfiguration

Without EX, sessions persist indefinitely in Redis even after the SDK
considers them expired. Compute remaining TTL from createdAt +
absoluteDuration - now so keys expire at the correct wall-clock time.
Apply the same TTL to the sid index key. Thread absoluteDuration through
the store factory so the Redis TTL stays in sync with sessionConfiguration.
nandan-bhat
nandan-bhat previously approved these changes Oct 7, 2026
Resolve the redis-store.ts conflict in the migration example. main (#53)
re-keyed the backchannel logout index to session:<sid>:<sub> and gated
the index write/delete on both sid and sub; this branch (#54) adds a TTL
(createdAt + absoluteDuration) to the session and index keys. The merged
set() keeps the sub+sid keying and applies the same EX ttl to the index
key, so both fixes hold together.

Co-Authored-By: Claude <noreply@anthropic.com>
nandan-bhat
nandan-bhat previously approved these changes Oct 7, 2026
…tion runbook

The backchannel-logout index was renamed to session:<sid>:<sub> in #53, but the
Scenario 2 steps still referenced logout:sid:<sid>, so `redis-cli keys 'logout:sid:*'`
returned nothing and the "confirm the index key exists" step could not succeed.
Point the runbook at the current key name and `keys 'session:*'`.

Also note that session and index keys now carry a Redis TTL (createdAt +
absoluteDuration): add a verification step using `redis-cli ttl` and mirror the
expiry behavior into the redis-store.ts docstring.

Co-Authored-By: Claude <noreply@anthropic.com>
cschetan77
cschetan77 previously approved these changes Oct 8, 2026
Comment thread examples/migration-express-openid-connect/after/src/redis-store.ts Outdated
…e.ts

Co-authored-by: Chetan Sharma <chetan.sharma@okta.com>
@nandan-bhat
nandan-bhat merged commit c4bf087 into main Oct 8, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants