Skip to content

Commit

Permalink
Merge pull request #226 from johngian/fix-222
Browse files Browse the repository at this point in the history
Return `None` when authenticate() request has no `state` or `code`
  • Loading branch information
johngian committed Apr 24, 2018
2 parents feab268 + 25c34e4 commit 6fe0347
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mozilla_django_oidc/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def authenticate(self, **kwargs):
session = self.request.session

if not code or not state:
raise SuspiciousOperation('Code or state not found.')
return None

reverse_url = import_from_settings('OIDC_AUTHENTICATION_CALLBACK_URL',
'oidc_authentication_callback')
Expand Down
3 changes: 1 addition & 2 deletions tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ def test_authenticate_no_code_no_state(self):
# there are no GET params
request = RequestFactory().get('/foo')
request.session = {}
with self.assertRaisesMessage(SuspiciousOperation, 'Code or state not found'):
self.backend.authenticate(request=request)
self.assertIsNone(self.backend.authenticate(request=request))

@override_settings(OIDC_USE_NONCE=False)
@patch('mozilla_django_oidc.auth.OIDCAuthenticationBackend._verify_jws')
Expand Down

0 comments on commit 6fe0347

Please sign in to comment.