pallets-eco/flask-wtf

Inconsistency with raising CSRFError

Offen

#381 geöffnet am 18.10.2019

 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (315 Forks)github user discovery
csrfdocsgood first issue

Repository-Metriken

Stars
 (1.508 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 3h 45m) (3 gemergte PRs in 30 T)

Beschreibung

The Flask-WTF docs state:

When CSRF validation fails, it will raise a CSRFError.

However, this appears to only be true, if this optional code has been used:

from flask_wtf.csrf import CSRFProtect
csrf = CSRFProtect(app)

When that code is not used, forms are created by subclassing FlaskForm, and CSRF validation fails, then validate_on_submit returns False instead of raising CSRFError.

It seems that ideally you would always raise CSRFError for consistency, but if you don't want to do that, then it would be helpful to update the docs.

Contributor Guide