-
Notifications
You must be signed in to change notification settings - Fork 126
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
Ability to handle multiple cookies in context #66
Comments
Could you elaborate on the issue? Although the masked token will be different across page (frame) loads, the unmasked token remains the same for the lifetime of the cookie, meaning any of the masked tokens should work when submitted? |
How can I provide to you more information? Here's the middleware:
I set the token in the template like this:
On form submission I include the CSRF token and check like this:
It works randomly, that's why I think it's overwriting the token/cookie depending on which iframe loads first on the screen
|
@justinas any thoughts on this? |
I think I understand the issue now. I do not yet have a good fix in mind for this. Is there a way in your case to make some initial request that would set the cookie? Then, you can load the two frames and they will operate on the existing cookie, and not set a new one. By the way, this seems like it will not work as expected: Expires: time.Now().Add(5 * time.Minute), This sets all nosurf cookies to expire at the absolute time "5 minutes after the middleware is initially constructed". I am not sure if In general, setting the cookie to such a short duration, will exacerbate such problems, as the cookies will expire more often. |
I'm afraid there's no possibility of an initial request as it's used by a 3rd party. |
Is there an
easyway to handle the scenario of multiple cookies in context and not just the defaultcsrf_token
?It's regarding an iframe integration scenario that the same frame will be included multiple times in the page and the way the library is now, each frame will overwrite the
csrf_token
meaning if the 1st form submits then it will have a different token than the latest in the context.For setting the tokens with different names I've managed to simply append the frameId inside the HandlerFunc but the problem is in the verification step where the context is the same.
The text was updated successfully, but these errors were encountered: