Skip to content

Commit f231476

Browse files
committed
Partiallly Revert "Remove workaround from check_csrf() (#6919)"
This workaround was missing 'if view is not None ' as found in https://github.com/pallets-eco/flask-wtf/pull/419/files Tested with MULTI_ORG enabled.
1 parent 53eab14 commit f231476

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

redash/security.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import functools
22

3-
from flask import session
3+
from flask import request, session
44
from flask_login import current_user
55
from flask_talisman import talisman
66
from flask_wtf.csrf import CSRFProtect, generate_csrf
@@ -35,6 +35,15 @@ def inject_csrf_token(response):
3535

3636
@app.before_request
3737
def check_csrf():
38+
# BEGIN workaround until https://github.com/lepture/flask-wtf/pull/419 is merged
39+
if request.blueprint in csrf._exempt_blueprints:
40+
return
41+
42+
view = app.view_functions.get(request.endpoint)
43+
if view is not None and f"{view.__module__}.{view.__name__}" in csrf._exempt_views:
44+
return
45+
# END workaround
46+
3847
if not current_user.is_authenticated or "user_id" in session:
3948
csrf.protect()
4049

0 commit comments

Comments
 (0)