Skip to content

Commit

Permalink
Remove legacy code related to base64 encoded secret.
Browse files Browse the repository at this point in the history
  • Loading branch information
johngian committed Jun 6, 2017
1 parent fcd9f53 commit e0e5ae3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
6 changes: 0 additions & 6 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ of ``mozilla-django-oidc``.

OpenID Connect client secret provided by your OP

.. py:attribute:: OIDC_RP_CLIENT_SECRET_ENCODED
:default: ``False``

Controls whether your client secret requires base64 decoding for verification

.. py:attribute:: OIDC_VERIFY_JWT
:default: ``True``
Expand Down
9 changes: 5 additions & 4 deletions mozilla_django_oidc/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ def verify_token(self, token, **kwargs):
"""Validate the token signature."""
nonce = kwargs.get('nonce')

secret = self.OIDC_RP_CLIENT_SECRET
if import_from_settings('OIDC_RP_CLIENT_SECRET_ENCODED', False):
secret = base64.urlsafe_b64decode(self.OIDC_RP_CLIENT_SECRET)
# Verify the token
verified_token = jws.verify(token, secret, algorithms=['HS256'])
verified_token = jws.verify(
token,
self.OIDC_RP_CLIENT_SECRET,
algorithms=['HS256']
)
# The 'verified_token' will always be a byte string since it's
# the result of base64.urlsafe_b64decode().
# The payload is always the result of base64.urlsafe_b64decode().
Expand Down
1 change: 0 additions & 1 deletion tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ def test_jwt_decode_params_verify_false(self, request_mock, jws_mock):
jws_mock.assert_has_calls(calls)

@override_settings(OIDC_USE_NONCE=True)
@override_settings(OIDC_RP_CLIENT_SECRET_ENCODED=False)
@patch('mozilla_django_oidc.auth.jws')
def test_jwt_failed_nonce(self, jwt_mock):
"""Test Nonce verification."""
Expand Down

0 comments on commit e0e5ae3

Please sign in to comment.