-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a CSRF test showing @unauth_csrf no longer falls through.
- Loading branch information
Showing
4 changed files
with
18 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,4 +136,4 @@ | |
) | ||
from .webauthn_util import WebauthnUtil | ||
|
||
__version__ = "5.4.2" | ||
__version__ = "5.4.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -658,3 +658,18 @@ def custom(): | |
}, | ||
) | ||
assert b"CSRF" not in response.data | ||
|
||
|
||
@pytest.mark.csrf(csrfprotect=True) | ||
def test_csrf_json_protect(app, client): | ||
# test sending CSRF token in json body for an unauth endpoint (/login) | ||
# In older code the @unauth_csrf() decorator would 'fall through' - if the | ||
# decorator CSRF checked failed it would fall through to the form CSRF check. | ||
# The decorator CSRF check returns a 400 JSON response. | ||
csrf_token = _get_csrf_token(client) | ||
response = client.post( | ||
"/login", | ||
json=dict(email="[email protected]", password="password", csrf_token=csrf_token), | ||
) | ||
assert response.status_code == 400 | ||
assert response.json["response"]["errors"][0] == "The CSRF token is missing." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,7 +153,7 @@ deps = | |
jinja2 | ||
skip_install = true | ||
commands = | ||
pybabel extract --version 5.4.2 --keyword=_fsdomain --project=Flask-Security \ | ||
pybabel extract --version 5.4.3 --keyword=_fsdomain --project=Flask-Security \ | ||
-o flask_security/translations/flask_security.pot \ | ||
--msgid-bugs-address[email protected] --mapping-file=babel.ini \ | ||
--add-comments=NOTE flask_security | ||
|