Firebase Hosting (Cloud Run) x Nextjs x NextAuth #5301
Replies: 3 comments 4 replies
-
Hi, thanks for sharing your approach. 🙂 I'm facing a similar issue right now. I'm adding a custom provider to my next app.
Your approach might work, but in my case I definitely also need the By any chance, did you gather any other new information on this topic. Best regards |
Beta Was this translation helpful? Give feedback.
-
Facing same issue on localhost I am getting session object of user with next auth but when i do firebase deploy and it creates SSR function there after login my getServerSideProp is not able to get session object. What I think that it is removing cookies related to session. Any solutions to this also on which platform did you shift so that it worked |
Beta Was this translation helpful? Give feedback.
-
Hey, still no proper solution for this ? |
Beta Was this translation helpful? Give feedback.
-
Hi, Team and contributors at NextAuth!
I wanted to share what I've learned setting up NextAuth with Firebase Hosting (and a cloud function v2 backend) and get some feedback on general thoughts/security concerns.
By combing through this repo's comments and other areas of the interweb (like this for example) , I found that Firebase Hosting strips all cookies besides
__session
.You can find more on that here: https://firebase.google.com/docs/hosting/manage-cache#using_cookies
I've found that the following configuration works for me:
Providers
Cookies
Security Concerns
Reading the NextAuth Docs, I noticed that changing cookie names seems to be antipattern.
It seems that each individual has its own key that is stored as its corresponding cookie (and incremented depending on value size), like so:
I would like to get y'alls thoughts on the security implications of setting a custom
state
cookie named__session
. It's unfortunate that Firebase Hosting does not seem to allow multiple session keys (this is a deal breaker for some, I feel like).Potential Feature Request?
Being that Firebase Hosting only allows the
__session
key as a cookie and that the current configuration for NextAuth requires multiple keys (per csrf token, state token, etc), I'm wondering if there is a way to store those four keys inside the same__session
cookie? Would this be a new feature to support this behavior? Is it even plausible or practical? Especially seeing that the cookie size limit is4096
bytes.Let me know what you all think! Thank you for giving this a read!
Beta Was this translation helpful? Give feedback.
All reactions