Fix: always pass tokenExpiration for frontend session cookies#154
Open
smakman wants to merge 1 commit intoauthsmith:mainfrom
Open
Fix: always pass tokenExpiration for frontend session cookies#154smakman wants to merge 1 commit intoauthsmith:mainfrom
smakman wants to merge 1 commit intoauthsmith:mainfrom
Conversation
For non-admin (frontend) logins, `useAdmin` is false, so the ternary `useAdmin ? collectionConfig.auth.tokenExpiration : undefined` was passing `undefined` to `createSessionCookies()`, which falls back to the hardcoded 7200s default. This means the collection's configured `auth.tokenExpiration` was being ignored for all frontend logins. Remove the `useAdmin` conditional and always pass `collectionConfig.auth.tokenExpiration` in OAuth authentication, password signin, and password signup flows. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
For non-admin (frontend) logins,
useAdminisfalse, so the ternary expression:passes
undefinedtocreateSessionCookies(), which then falls back to the hardcoded 7200s (2 hour) default. This means the collection's configuredauth.tokenExpirationis silently ignored for all frontend logins — only admin logins respect it.This affects three flows:
src/core/protocols/oauth/oauth_authentication.ts)src/core/protocols/password.ts—PasswordSignin)src/core/protocols/password.ts—PasswordSignup)Fix
Remove the
useAdminconditional and always passcollectionConfig.auth.tokenExpirationtocreateSessionCookies(), so both admin and frontend session cookies use the collection's configured token expiration.Before:
After:
Test plan
auth.tokenExpiration(e.g. 86400 for 24h)allowAutoSignin: trueand verify the session cookie expiration is correct🤖 Generated with Claude Code