-
Notifications
You must be signed in to change notification settings - Fork 141
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
V2 cookies are huge #143
Comments
Hi @piec - thanks for raising this In v2 we wanted to simplify the advice on getting/persisting access tokens. So we went for storing them, along with ID tokens, in the cookie session by default. The tradeoff we made was that now the cookies can get larger, and so we added cookie chunking in to avoid hitting browser limits on individual cookie size (~4kb) If I run the sample app with an Auth0 account and set {
"id_token": "[a JWT ~1,900 chars long]",
"access_token": "An opaque token ~30 chars long",
"token_type": "Bearer",
"expires_at": 1601551231
} Which serializes (encrypted) to about 2.8kb. If my access token was a JWT as well, or I had a bunch more claims in my ID token this size would increase, perhaps to slightly over 4kb, so in the case of nginx I would have to update my server configuration to allow for this.
Assuming you want to persist a user's logged in state and access an api, then you need to persist the ID Token and Access Token. As an aside - we're planning to add a feature to allow the user to provide an We're also planning on adding extensibility points into the library as hooks - so you can have more fine grained control over what is stored in the session. |
Thanks for this detailed answer, I understand the tradeoff. Adding the option to use an external store (or not storing at all) and external hooks is great :) |
Hey @piec - just to let you know that we've released See the example snippet: https://github.com/auth0/express-openid-connect/blob/2.3-beta/EXAMPLES.md#9-use-a-custom-session-store and example app: https://github.com/auth0/express-openid-connect/blob/2.3-beta/examples/custom-session-store.js You can try it out by installing the beta from npm |
Thank you @adamjmcgrath I will take a look at it and try |
Experiencing the same, anything new on this? |
Hi,
Thank you for your work on v2.
In my use case I need to call userinfo and the v2 api makes it really simple. In v1 I have to keep around users' tokenset with express-session for example.
The issue I have is the size of the appSession cookies (plural because they are chunked in several cookies).
A bit more than 4k in my case, is it due to my setup? (I guess a tokenset is stored in the cookies which explains the simplified userinfo api). V1 appSession cookies are ~500 bytes.
For each request+response from the browser to the api the cookies are sent as part of the request and updated cookies are sent from the api.
I think I wouldn't have noticed immediately but the default configuration of nginx (used as reverse proxy in front of the api) doesn't let these large headers go through: (due to the cookie size I think)
nginx can be configured to allow this using for example:
What do you think about it?
The tokenset has to be stored somewhere but it's not always needed for very simple usecases right?
The text was updated successfully, but these errors were encountered: