Skip to content

Commit

Permalink
Check for request.endpoint before use.
Browse files Browse the repository at this point in the history
  • Loading branch information
salsa-nathan committed Mar 26, 2021
1 parent 215aa4b commit 35f04d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ckanext/fortify/anti_csrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def after_request_function(response):
# config_option_update is trying to update token so we need to skip applying the token
# to this form
# TODO: Fix me!
if request.endpoint in ('admin.config'):
if request.endpoint and request.endpoint in ('admin.config'):
return response
token = _get_response_token(request, resp)
new_response = _apply_token(resp.get_data(as_text=True), token)
Expand Down Expand Up @@ -161,7 +161,7 @@ def is_secure():
def is_safe():
"Check if the request is 'safe', if the request is safe it will not be checked for csrf"
# api requests are exempt from csrf checks
if request.path.startswith("/api") or request.endpoint in ('admin.config'):
if request.path.startswith("/api") or (request.endpoint and request.endpoint in ('admin.config')):
return True

# get/head/options/trace are exempt from csrf checks
Expand Down

0 comments on commit 35f04d7

Please # to comment.