Skip to content

Commit

Permalink
Switch CSRF token from per-request to per-session
Browse files Browse the repository at this point in the history
This patch switches the CSRF token handling from per-request to
per-session. The per-request behavior was overly aggressive, and it
restricted parallel browsing (e.g. multiple open browser tabs).
  • Loading branch information
anishathalye committed Dec 28, 2019
1 parent 808c2c2 commit e0d4def
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gavel/controllers/csrf_protection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@app.before_request
def csrf_protect():
if request.method == "POST":
token = session.pop('_csrf_token', None)
token = session.get('_csrf_token', None)
if not token or token != request.form.get('_csrf_token'):
abort(403)

Expand Down

0 comments on commit e0d4def

Please sign in to comment.