Custom cookie creation (size limitation workaround) #2628
Replies: 20 comments 9 replies
-
Thank you for this issue. To overcome this, currently you could utilize a database adapter. We offer quite a few options: https://next-auth.js.org/adapters/overview Would be also interesting to know if you are interested in creating a PR for this with your ideal implementation? 🙂 Ideally you could fill out the entire issue template you probably skipped, so others can evaluate your suggestion as well. |
Beta Was this translation helpful? Give feedback.
-
Out of curiosity how long are the cognito |
Beta Was this translation helpful? Give feedback.
-
@balazsorban44 thank you but unfortunately our service does not store any data. |
Beta Was this translation helpful? Give feedback.
-
@mtt87 refresh token is about 1700 b and the session token, which consists of a few profile properties & the access token is around 1850. total size is below chrome's limit but the browser was still printing warnings. |
Beta Was this translation helpful? Give feedback.
-
would be interesting to know what is inside the access token? We use IdentityServer 4, and by not adding identity claims to the access token, we could spare a lot of space. Could you share your |
Beta Was this translation helpful? Give feedback.
-
@digitalhank can you share your current solution for this? I'm facing the same issue using keycloak provider |
Beta Was this translation helpful? Give feedback.
-
@dennervidal something like this
|
Beta Was this translation helpful? Give feedback.
-
Out of curiosity how do you refresh the token? Doesn’t seem like you handle it in the code posted here |
Beta Was this translation helpful? Give feedback.
-
yeah i removed it for brevity. my refreshAccessToken function is quite similar to the docs |
Beta Was this translation helpful? Give feedback.
-
OT have you ever experienced issues with refresh token rotation? We are working on fixing some stuff but would be curious to hear if you ever noticed any issue with your cognito setup |
Beta Was this translation helpful? Give feedback.
-
Not yet. My implementation is fairly new so it hasn't been thoroughly tested yet. I can report back if anything unexpected happens. |
Beta Was this translation helpful? Give feedback.
-
Hi @digitalhank. I'm running into the same issue. Thank you for posting your code example above. I'm new to Next.js. Would you mind posting a quick example of how you are calling Auth in your code? Are you even using the [...nextauth].js with a setup in _app.js or are you handling that in some other manner? |
Beta Was this translation helpful? Give feedback.
-
@indianabenny the only significant difference between how it's invoked in the docs and my implementation is that I am wrapping the NextAuth function with the |
Beta Was this translation helpful? Give feedback.
-
This workaround is pretty neat actually. I've been working with keycloak auth services, and had to apply this in my app to work properly. Only thing I say to you who had the same problem using JWT is to pay attention on session time and cookie expiration (Keycloak is not a default provider, so the management is totally on me). In order to auto refresh the tokens, set the provider options. I think this should be considered in future versions of next-auth, since not every JWT is short enough to fit in a cookie. |
Beta Was this translation helpful? Give feedback.
-
See another example here for how this can be solved: |
Beta Was this translation helpful? Give feedback.
-
Hi there! It looks like this issue hasn't had any activity for a while. It will be closed if no further activity occurs. If you think your issue is still relevant, feel free to comment on it to keep it open. (Read more at #912) Thanks! |
Beta Was this translation helpful? Give feedback.
-
This is still an issue. |
Beta Was this translation helpful? Give feedback.
-
Im having issues storing refresh token ...if i to a substr and take just part of it , i dont get errors... |
Beta Was this translation helpful? Give feedback.
-
Update, cookie chunking is on the way! #3101 🎉 |
Beta Was this translation helpful? Give feedback.
-
Summary 💭
Due to the size limitations of cookies, i cannot store both the refresh & access token i am receiving from Cognito in the session cookie. It would be incredibly favourable if the library allowed you to a create cookies arbitrarily so that i for instance, could store the refresh token inside a separate cookie.
Edit - i realize this is fairly trivial to implement yourself but it would be nice if the library offered this feature oob.
Beta Was this translation helpful? Give feedback.
All reactions