fix: 30 day sliding session TTL instead of a hard 24h expiry - #22
Merged
Conversation
Sessions expired after 24h, so every hosted OAuth user had to complete a full browser sign-in daily. The DS access token behind the session is valid for 365 days, so our own TTL - not the DS token - was forcing it: DS access token life : 365 days our session TTL : 24 hours <- binding constraint We issue no refresh_token and advertise only the authorization_code grant, so a client has no way to renew without user interaction. Raise TTL.SESSION to 30 days and slide it forward on each authenticated request, so an actively used connection never expires; 30 days becomes an inactivity window rather than a hard cap. Kept well inside the DS token's life because a session ID is a bearer credential. The slide only writes when the expiry has moved by more than an hour, so a busy session touches the store about hourly rather than per request, and it is fire-and-forget: a failed extension never fails the user's request. Verified: TTL.SESSION = 2592000s (30d), which is also the expires_in we advertise. Sliding is covered in both directions - an active session survives 50 days of use, an unused one still expires, and touchSession will not resurrect an already-expired session.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
OAuth sessions expired after 24h, so every hosted user had to complete a full browser sign-in daily.
The interesting part is why. Decoding the DS access token from a live dev session:
The DS token is good for a year. Our own TTL was forcing re-authentication — and since we issue no
refresh_tokenand advertise only theauthorization_codegrant, a client has no way to renew without user interaction.This also corrects the earlier plan to implement token refresh: refresh solves an expiry we don't actually have.
Change
TTL.SESSION: 24h → 30 daystouchSession), so an actively used connection never expires. 30 days becomes an inactivity window rather than a hard cap.Kept well inside the DS token's 365-day life because a session ID is a bearer credential.
Two implementation details:
Verification
Built server reports
TTL.SESSION = 2592000s(30 days), which is also theexpires_inwe advertise to clients.New tests cover both directions:
touchSessionwill not resurrect an already-expired sessionThe existing
exposes TTLs in secondstest is updated, plus a new intent-based assertion (> 7 days,< 365 days) so the reasoning is pinned, not just the constant.553 tests passing (was 547). Lint and format clean.