Giter VIP home page Giter VIP logo

Comments (5)

justinas avatar justinas commented on May 5, 2024

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.

NCSantos avatar NCSantos commented on May 5, 2024

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.

justinas avatar justinas commented on May 5, 2024

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.

NCSantos avatar NCSantos commented on May 5, 2024

I am using curl to do the requests and was not correctly sending and saving the cookies.
Thanks for your help.

from nosurf.

justinas avatar justinas commented on May 5, 2024

No problem, please re-open the issue if you encounter such troubles again.

from nosurf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.