Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 32cc8b8

Browse files
committed
Revert "Don't use a special claim for the parsed and verified JWT. It's already present in the .jwt attribute"
This reverts commit 8d827a2
1 parent 8d827a2 commit 32cc8b8

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

src/oidcmsg/oidc/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def verify_id_token(msg, check_hash=False, **kwargs):
312312
if idt["c_hash"] != left_hash(msg["code"], hfunc):
313313
raise CHashError("Failed to verify code hash", idt)
314314

315-
msg["id_token"] = idt
315+
msg[verified_claim_name("id_token")] = idt
316316
logger.info('Verified ID Token: {}'.format(idt.to_dict()))
317317

318318
return True
@@ -459,7 +459,7 @@ def verify(self, **kwargs):
459459
self.update(oidr)
460460

461461
# replace the JWT with the parsed and verified instance
462-
self["request"] = oidr
462+
self[verified_claim_name("request")] = oidr
463463

464464
if "id_token_hint" in self:
465465
if isinstance(self["id_token_hint"], str):

src/oidcmsg/oidc/session.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from ..message import SINGLE_REQUIRED_STRING
1111
from ..oauth2 import ResponseMessage
1212
from ..oidc import clear_verified_claims
13+
from ..oidc import verified_claim_name
1314
from ..oidc import IdToken
1415
from ..oidc import ID_TOKEN_VERIFY_ARGS
1516
from ..oidc import MessageWithIdToken
@@ -65,7 +66,7 @@ def verify(self, **kwargs):
6566
return False
6667

6768
# Add the verified ID Token to the message instance
68-
self["id_token_hint"] = idt
69+
self[verified_claim_name("id_token_hint")] = idt
6970

7071
return True
7172

@@ -166,7 +167,7 @@ def verify(self, **kwargs):
166167
if not idt.verify(**kwargs):
167168
return False
168169

169-
self["logout_token"] = idt
170+
self[verified_claim_name("logout_token")] = idt
170171
logger.info('Verified ID Token: {}'.format(idt.to_dict()))
171172

172173
return True

tests/test_6_oidc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
from oidcmsg.oidc import msg_ser
5151
from oidcmsg.oidc import msg_ser_json
5252
from oidcmsg.oidc import scope2claims
53+
from oidcmsg.oidc import verified_claim_name
5354
from oidcmsg.time_util import utc_time_sans_frac
5455

5556
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
@@ -850,7 +851,7 @@ def test_at_hash():
850851

851852
at = AuthorizationResponse(**_info)
852853
assert at.verify(keyjar=keyjar, sigalg="HS256")
853-
assert 'at_hash' in at['id_token']
854+
assert 'at_hash' in at[verified_claim_name('id_token')]
854855

855856

856857
def test_c_hash():
@@ -879,7 +880,7 @@ def test_c_hash():
879880

880881
at = AuthorizationResponse(**_info)
881882
r = at.verify(keyjar=keyjar, sigalg="HS256")
882-
assert 'c_hash' in at['id_token']
883+
assert 'c_hash' in at[verified_claim_name('id_token')]
883884

884885

885886
def test_missing_c_hash():

tests/test_7_session.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010

1111
from oidcmsg.exception import MessageException
1212
from oidcmsg.exception import NotForMe
13+
from oidcmsg.oidc import verified_claim_name
1314
from oidcmsg.oidc import Claims
1415
from oidcmsg.oidc import ClaimsRequest
1516
from oidcmsg.oidc import IdToken
16-
from oidcmsg.oidc.session import BACK_CHANNEL_LOGOUT_EVENT
17-
from oidcmsg.oidc.session import BackChannelLogoutRequest
17+
from oidcmsg.oidc.session import BACK_CHANNEL_LOGOUT_EVENT, \
18+
BackChannelLogoutRequest
1819
from oidcmsg.oidc.session import LogoutToken
1920
from oidcmsg.oidc.session import CheckSessionRequest
2021
from oidcmsg.oidc.session import EndSessionRequest
@@ -80,9 +81,11 @@ def test_example(self):
8081
keyjar.add_symmetric(CLIENT_ID, _key.key)
8182
request.verify(keyjar=keyjar)
8283
assert isinstance(request, EndSessionRequest)
83-
assert set(request.keys()) == {'id_token_hint', 'redirect_url', 'state'}
84+
assert set(request.keys()) == {verified_claim_name('id_token_hint'),
85+
'id_token_hint', 'redirect_url', 'state'}
8486
assert request["state"] == "state0"
85-
assert request["id_token_hint"]["aud"] == ["client_1"]
87+
assert request[
88+
verified_claim_name("id_token_hint")]["aud"] == ["client_1"]
8689

8790

8891
class TestCheckSessionRequest(object):

0 commit comments

Comments
 (0)