Skip to content

Commit 6865301

Browse files
committed
Fix Errors
1 parent ba4d765 commit 6865301

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

docs/oidc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ This feature has to be enabled separately as it is an extension to the core stan
160160
# OIDC has to be enabled to use RP-Initiated Logout
161161
"OIDC_ENABLED": True,
162162
# Enable and configure RP-Initiated Logout
163-
"OIDC_RP_INITIATED_LOGOUT": True,
163+
"OIDC_RP_INITIATED_LOGOUT_ENABLED": True,
164164
"OIDC_RP_INITIATED_LOGOUT_ALWAYS_PROMPT": True,
165165
# ... any other settings you want
166166
}

oauth2_provider/views/oidc.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from django.views.generic import FormView, View
1010
from jwcrypto import jwk, jwt
1111
from jwcrypto.common import JWException
12+
from jwcrypto.jws import InvalidJWSObject
1213
from jwcrypto.jwt import JWTExpired
1314
from oauthlib.common import add_params_to_uri
1415

@@ -158,7 +159,13 @@ def _load_id_token(token):
158159
IDToken = get_id_token_model()
159160
validator = oauth2_settings.OAUTH2_VALIDATOR_CLASS()
160161

161-
key = validator._get_key_for_token(token)
162+
try:
163+
key = validator._get_key_for_token(token)
164+
except InvalidJWSObject:
165+
# Failed to deserialize the key.
166+
return None, None
167+
168+
# Could not identify key from the ID Token.
162169
if not key:
163170
return None, None
164171

tests/test_oidc_views.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ def test_validate_logout_request(oidc_tokens, public_application, other_user, rp
265265
)
266266

267267

268+
def test__load_id_token():
269+
assert _load_id_token("Not a Valid ID Token.") == (None, None)
270+
271+
268272
def is_logged_in(client):
269273
return get_user(client).is_authenticated
270274

0 commit comments

Comments
 (0)