-
Notifications
You must be signed in to change notification settings - Fork 425
Extensive Cookie Configuration #2059
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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:
|
Hey are there any blockers to merging and releasing this? Thanks for authoring this PR! |
these changes have been made
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
Fixes #1889
Changes
This PR introduces enhanced configuration options for session cookies, allowing for finer control over their attributes.
SessionCookieOptions
:domain
: Specifies theDomain
attribute for the session cookie.transient
: Iftrue
, themaxAge
attribute is omitted, making the cookie a session cookie (deleted when the browser closes). Defaults tofalse
.AUTH0_COOKIE_DOMAIN
AUTH0_COOKIE_PATH
AUTH0_COOKIE_TRANSIENT
AUTH0_COOKIE_SECURE
AUTH0_COOKIE_SAME_SITE
setChunkedCookie
: Logic adjusted to handle thetransient
option by omittingmaxAge
.Auth0Client
: Initialization logic now incorporates values from environment variables as defaults if direct configuration is not provided.AbstractSessionStore
: Now passesdomain
andtransient
options during cookie configuration.Testing
src/server/chunked-cookies.test.ts
to verify the correct behavior of the newdomain
andtransient
options 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.local
file 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
Auth0ClientOptions
take precedence over environment variables.