You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you can see, the way I'm passing the token to the server is by reading the value from gorilla.csrf.Token input field.
My question is: if my page needs to make multiple javascript POST requests to the server, can I use the same CSRF token (from the input field) in all of the requests?
Or... for each request, I need to renew the CSRF token in the server, and use a new token for each subsequent request?
Thanks!
@elithrar - if you have a spare minute and could add a comment here I'd appreciate it 🙂
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi,
I'm trying to understand how to properly use Gorilla CSRF in Javascript applications.
In my application, I include the hidden field with the CSRF token, like this:
<input type="hidden" name="gorilla.csrf.Token" value="3jCudIoHw/pMIeP4wsvgM1AmR8n2rKmob0v66FWKP0kqxjj1gSWaLDLAmKIslnKCc4n7SbgxFEe4hqHrNI2bvA==">
Then, I have some Javascript events that might POST (ajax) to the server, for example:
As you can see, the way I'm passing the token to the server is by reading the value from
gorilla.csrf.Token
input field.My question is: if my page needs to make multiple javascript POST requests to the server, can I use the same CSRF token (from the input field) in all of the requests?
Or... for each request, I need to renew the CSRF token in the server, and use a new token for each subsequent request?
Thanks!
@elithrar - if you have a spare minute and could add a comment here I'd appreciate it 🙂
Beta Was this translation helpful? Give feedback.
All reactions