Skip to content

Commit

Permalink
protect the delete method by default
Browse files Browse the repository at this point in the history
simplify exempt checks
  • Loading branch information
davidism committed Oct 13, 2016
1 parent 682e695 commit 2954c77
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions flask_wtf/csrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def __init__(self, app=None):
def init_app(self, app):
app.config.setdefault('WTF_CSRF_ENABLED', True)
app.config.setdefault('WTF_CSRF_CHECK_DEFAULT', True)
app.config.setdefault('WTF_CSRF_METHODS', ['POST', 'PUT', 'PATCH'])
app.config['WTF_CSRF_METHODS'] = set(app.config.get(
'WTF_CSRF_METHODS', ['POST', 'PUT', 'PATCH', 'DELETE']
))
app.config.setdefault('WTF_CSRF_HEADERS', ['X-CSRFToken', 'X-CSRF-Token'])
app.config.setdefault('WTF_CSRF_SSL_STRICT', True)

Expand All @@ -125,14 +127,13 @@ def _csrf_protect():
if not view:
return

if self._exempt_views or self._exempt_blueprints:
dest = '%s.%s' % (view.__module__, view.__name__)
if request.blueprint in self._exempt_blueprints:
return

if dest in self._exempt_views:
return
dest = '%s.%s' % (view.__module__, view.__name__)

if request.blueprint in self._exempt_blueprints:
return
if dest in self._exempt_views:
return

self.protect()

Expand Down

0 comments on commit 2954c77

Please sign in to comment.