-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
feat: deep-merge cookies options #9386
Conversation
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
@yordis is attempting to deploy a commit to the authjs Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Ignored Deployments
|
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.
Thanks! First I was hesitant, but this keeps the current defaults, so it should be safe.
However, some other tweaks were needed, which I applied.
Hey @balazsorban44 is there any opportunity to release this feature 🙏🏻 |
Context
Recently we had to manually configure the
cookies
in order to get our API service to authenticate with the NextAuthcookie session token. Because the API lives under
api.example.com
and the NextJS app lives underexample.com
we hadto set the
domain
property of the cookie to.example.com
in order to get the cookie to be sent to the API.Here is the relevant code:
Concern
In order to accomplish this, we have to overwrite the entire cookie configuration. This means that we have to
manually set the
httpOnly
,sameSite
,path
,secure
, etc. properties. This is not ideal because if the NextAuthteam ever changes the default values for these properties, we will not get the benefit of those changes.
Or if new sensible defaults are added, we will not get those either.
It is critical to have secured and sensible defaults for these properties.
Also notice the error-prone nature of this code since it requires to understand interanlly how NextAuth works and how
cookies work in general. Adding
__Secure-
,__Host-
(which middlewares in other languages relies on), or extremelycritical, make sure
secure
is set totrue
in production.Breaking Change?
Since we must overwrite the entire cookie configuration as of today, this should not be a breaking change as far as I
can tell.