Skip to content

Commit

Permalink
fixed csrf
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Oct 27, 2019
1 parent 4eb18e6 commit e5cbcb9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion masonite/middleware/CsrfMiddleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def verify_token(self):
"""

if self.request.is_post() and not self.in_exempt():
token = self.request.header('X-CSRF-TOKEN') or self.request.input('__token')
token = self.request.header('HTTP_X_CSRF_TOKEN') or self.request.input('__token')
if not self.csrf.verify_csrf_token(token):
raise InvalidCSRFToken("Invalid CSRF token.")
return token
Expand Down
1 change: 1 addition & 0 deletions masonite/testing/TestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def call(self, method, url, params, wsgi={}):

custom_wsgi.update(wsgi)
if not self._with_csrf:
print('set the csrf tokens')
params.update({'__token': 'tok'})
custom_wsgi.update({
'HTTP_COOKIE': 'csrf_token=tok',
Expand Down
4 changes: 2 additions & 2 deletions tests/core/test_csrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def test_csrf_with_dashes(self):
.post('/test-route'))

def test_csrf_can_use_header(self):
(self.withCsrf()
(self.withoutCsrf()
.withHeaders({
'X-CSRF-TOKEN': 'xx'
'X-CSRF-TOKEN': 'tok'
})
.post('/test-route'))

0 comments on commit e5cbcb9

Please sign in to comment.