Skip to content

Commit

Permalink
Merge pull request #392 from akatsoulas/oidc-kid-setting
Browse files Browse the repository at this point in the history
fix(auth): merge suggestion of @cfra to prevent KeyError in auth.py
  • Loading branch information
akatsoulas committed Dec 24, 2020
2 parents 476f7af + e58e4f6 commit d3fd7ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ of ``mozilla-django-oidc``.

Controls whether the OpenID Connect client verifies the signature of the JWT tokens

.. py:attribute:: OIDC_VERIFY_KID
:default: ``True``

Controls whether the OpenID Connect client verifies the KID field of the JWT tokens

.. py:attribute:: OIDC_USE_NONCE
:default: ``True``
Expand Down
4 changes: 2 additions & 2 deletions mozilla_django_oidc/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from mozilla_django_oidc.utils import absolutify, import_from_settings


LOGGER = logging.getLogger(__name__)


Expand Down Expand Up @@ -159,7 +158,8 @@ def retrieve_matching_jwk(self, token):

key = None
for jwk in jwks['keys']:
if 'kid' in jwk and jwk['kid'] != smart_text(header.kid):
if (import_from_settings("OIDC_VERIFY_KID", True)
and jwk['kid'] != smart_text(header.kid)):
continue
if 'alg' in jwk and jwk['alg'] != smart_text(header.alg):
continue
Expand Down

0 comments on commit d3fd7ff

Please sign in to comment.