Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2059 +/- ##
==========================================
+ Coverage 82.53% 82.68% +0.15%
==========================================
Files 21 21
Lines 1941 1958 +17
Branches 342 347 +5
==========================================
+ Hits 1602 1619 +17
Misses 333 333
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
nandan-bhat
previously approved these changes
Apr 15, 2025
nandan-bhat
previously approved these changes
Apr 21, 2025
|
Hey are there any blockers to merging and releasing this? Thanks for authoring this PR! |
nandan-bhat
previously approved these changes
Apr 24, 2025
frederikprijck
previously requested changes
Apr 24, 2025
these changes have been made
gyaneshgouraw-okta
approved these changes
Apr 25, 2025
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the cookie configuration by introducing support for additional attributes (domain and transient), allowing finer control over session cookie behavior. Key changes include:
- Extending the SessionCookieOptions interface with new properties (domain and transient)
- Updating cookie setting logic in setChunkedCookie to omit the maxAge attribute when transient is enabled
- Adding environment variable support and updating corresponding documentation and tests
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/server/session/abstract-session-store.ts | Extends cookie options with domain and transient attributes. |
| src/server/cookies.ts | Adjusts setChunkedCookie logic to handle transient cookies. |
| src/server/client.ts | Updates session options to merge new cookie attributes with environment variable overrides. |
| src/server/chunked-cookies.test.ts | Adds tests to verify correct handling of domain and transient cookie configurations. |
| README.md | Updates documentation to detail the new cookie configuration options. |
| EXAMPLES.md | Provides updated examples on how to configure the new cookie options. |
nandan-bhat
approved these changes
Apr 25, 2025
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.
Fixes #1889
Changes
This PR introduces enhanced configuration options for session cookies, allowing for finer control over their attributes.
SessionCookieOptions:domain: Specifies theDomainattribute for the session cookie.transient: Iftrue, themaxAgeattribute is omitted, making the cookie a session cookie (deleted when the browser closes). Defaults tofalse.AUTH0_COOKIE_DOMAINAUTH0_COOKIE_PATHAUTH0_COOKIE_TRANSIENTAUTH0_COOKIE_SECUREAUTH0_COOKIE_SAME_SITEsetChunkedCookie: Logic adjusted to handle thetransientoption by omittingmaxAge.Auth0Client: Initialization logic now incorporates values from environment variables as defaults if direct configuration is not provided.AbstractSessionStore: Now passesdomainandtransientoptions during cookie configuration.Testing
src/server/chunked-cookies.test.tsto verify the correct behavior of the newdomainandtransientoptions for both single and chunked cookies.Usage
You can configure the new cookie options either through environment variables or directly in the SDK initialization.
1. Using Environment Variables:
Set the desired environment variables in your
.env.localfile or your deployment environment:The SDK will automatically pick up these values.
2. Using
Auth0ClientOptions(App Router Example):Configure the options directly when initializing the client handlers:
Note: Options provided directly in
Auth0ClientOptionstake precedence over environment variables.