Coder Social home page Coder Social logo

Comments (7)

stopspazzing avatar stopspazzing commented on June 19, 2024

awesome, thanks for letting me know. Seems you may have been right, never fully tested it just added it cause I could. I'm updating my code. However, seems you broke form.validate() 😢

from sanic-mdl-blog.

pyx avatar pyx commented on June 19, 2024

Could you elaborate what happen to form.validate()? Much appreciated.

from sanic-mdl-blog.

pyx avatar pyx commented on June 19, 2024

It may be related to the request object, the reasoning is here : pyx/sanic-wtf#6 , in short, we have to somehow keep a copy of current request object, because Sanic is sharing threads among many routes (view functions), a thread-local request object does not work in this case, so I decided to have the whole request being passed in in form construction.

Please let me know if you have a better idea. Thanks.

from sanic-mdl-blog.

pyx avatar pyx commented on June 19, 2024

I think I know what you mean, in 1148a0f
you removed the {{ form.hidden_tag }} call, but forgot to render the csrf token with {{ form.csrf_token }}

For CSRF protection to work, a hard-to-guess randomly-generated unique token is used with each request, the client should submit the token with other payloads to prove that the request is genuine.
The csrf token submission usually involve hidden field for normal HTML form submission, or special http header when using Restful API, in either way, the csrf token should be known by the client, that's why we need to rendered the hidden tag in the form ({{ form.csrf_token }}) to begin with.

You can learn more about CSRF here and here

from sanic-mdl-blog.

pyx avatar pyx commented on June 19, 2024

FYI, I just release 0.5.0 with file uploading support. Anything before that does not work well with file upload, unless you pass in the request.files explicitly.

from sanic-mdl-blog.

stopspazzing avatar stopspazzing commented on June 19, 2024

awesome, thanks. Going to be useful when i have to add uploading pictures. adding csrf now.

from sanic-mdl-blog.

stopspazzing avatar stopspazzing commented on June 19, 2024

crsf works properly, was my fault for not reading all of the docs. thanks.

from sanic-mdl-blog.

Related Issues (6)

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.