V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
llllllLllll
V2EX  ›  Python

问一个 flask-wtf 的问题

  •  
  •   llllllLllll · Oct 23, 2018 · 2269 views
    This topic created in 2742 days ago, the information mentioned may be changed or developed.
    flask-wtf 可以防御 csrf,通过校验 csrf_token 实现的。请问 validate_on_submit 函数的功能应该会校验表单提交的数据同时校验 csrf_token 吧,如果是的话能否告知一下在哪部分源码实现的。感谢大佬。
    6 replies    2018-10-29 17:35:22 +08:00
    rogwan
        1
    rogwan  
       Oct 23, 2018
    看看是不是这个地方:.../flask_wtf/csrf.py

    class CSRFProtect(object):
    ...
    leconio
        2
    leconio  
       Oct 23, 2018 via Android
    战斗砖块剧场(≧ω≦)/
    frostming
        3
    frostming  
       Oct 24, 2018   ❤️ 1
    https://github.com/lepture/flask-wtf/blob/master/flask_wtf/csrf.py#L144

    validate_csrf_token 函数会 validate 名叫 csrf_token 的 Field

    CSRFProtect 类是全站保护,上面的只是表单保护
    llllllLllll
        4
    llllllLllll  
    OP
       Oct 24, 2018
    @frostming thx !
    llllllLllll
        5
    llllllLllll  
    OP
       Oct 26, 2018
    @frostming 请问在处理一个请求时在哪里使用了 validate_csrf_token 函数来验证 csrf_token,thx。
    frostming
        6
    frostming  
       Oct 29, 2018
    @llllllLllll 你调 form.validate()或 form.validate_on_submit()的时候
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   824 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 20:49 · PVG 04:49 · LAX 13:49 · JFK 16:49
    ♥ Do have faith in what you're doing.