Comments (5)
Hi @NCSantos,
The token is only regenerated when the cookie either expires (after 365 days by default), is deleted, or corrupted (i.e. token can not be decoded from the cookie). What you see changing every time is the masked token: 32 byte random key and 32 byte encrypt(key, token)
payload. The unencrypted token stays the same for a long time and thus can be reused.
As long as the third party website can not acquire any of the tokens, this seems fine.
See this part in token.go and this part in handler.go.
Hope that answers your question.
from nosurf.
Hi @justinas ,
When calling the GET also regenerate the token, e.g.:
Call GET, call POST with token from GET, call GET again, call POST with token from first GET is not valid.
from nosurf.
I think you are misunderstanding what actually happens. The token in the cookie is unmasked, you can check it: it should not change whether you GET or POST as many times as you'd like. This is the value we care about. The thing that changes is the token for the forms (masked). To be more exact, this token's masking key is regenerated on every request, but the same token is masked every time.
Nosurf does not aim to prevent guarantees from double-submit of requests.
from nosurf.
I am using curl
to do the requests and was not correctly sending and saving the cookies.
Thanks for your help.
from nosurf.
No problem, please re-open the issue if you encounter such troubles again.
from nosurf.
Related Issues (20)
- Filtering out safe methods and excluded paths HOT 2
- Token value error HOT 6
- Send a response body in defaultFailureHandler HOT 2
- please consider updating tags or deleting the current tag HOT 3
- example is insecure HOT 4
- Remove Referer check HOT 1
- Possible flaw HOT 2
- SetBaseCookie not having effect HOT 8
- Wiki page for newbies doubts and problems
- Doubts about many cookies and many Path for a single domain. HOT 13
- Prevent form resubmit HOT 1
- Logging HOT 1
- Combining Session and CSRF cookie HOT 3
- RegenerateToken generates two CSRF cookies when no previous CSRF cookie was set
- How does nosurf OTP protect against BREACH? HOT 5
- Inappropriate key in call to `context.WithValue`
- Ability to handle multiple cookies in context HOT 5
- Installing command of `nosurf` is missing in README.md
- CSRF failed with bad request HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nosurf.