nuxt-auth-utils
nuxt-auth-utils copied to clipboard
Bypass 4096-byte limit
I am currently in the process of connecting my company's own internal OAuth IDP via nuxt-auth-utils. I need the access & refresh token in my session.
I need the access token to send it with my API requests in the authorization header (this happens on the server and client side). I need the refresh token to request a new access token if it has expired (this happens on the server side, although I don't yet know exactly how best to implement this :/).
With the two tokens I clearly exceed the 4096-byte limit. What is the best way to store these tokens? I would not like to set up an extra PostgreSQL database for this small use case. Does anyone have any helpful ideas for me?
If anyone has any ideas on how best to implement the refresh token flow, I would also be very grateful. :)
Translated with DeepL.com (free version)
+1 this limit has stopped me from using this lib because the JWT I receive is very large and I don't have the ability to shrink it down. Any chance that chunking will be implemented?
+1
+1
+1
+1
I think the only solution is break out some information to separate cookies. Issue is will this plugin manage for us, or we manage ourself separately
The problem is with H3 that does not have cookie chunking for the session data, which is used by nuxt-auth-utils. See https://github.com/h3js/h3/blob/main/src/utils/session.ts
Yes, so I manually add another httponly cookie for store refreshtoken and etc. with some encryption.
I've created this issue in H3: https://github.com/h3js/h3/issues/1062
I believe this issue here can be closed.
Chunking of session cookie is coming in H3 v3, which will be used by Nuxt v5. We'll have to wait a bit and keep the workarounds around.
Thank you for this awesome work @DavidDeSloovere
In the meantime, you can for instance use Nitro's KV storage to store the content of the session based using the session.id as key so you can limit only the data you store in the cookie. You will have to configure the Nitro storage to use a persistent storage in production like Redis.
Thanks for the workaround details, and thanks also to @DavidDeSloovere for your work.
I would leave the issue open for now until Nuxt v5 is released and cookie chunking is implemented here.