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

Commit 8d827a2

Browse files
committed
Don't use a special claim for the parsed and verified JWT.
It's already present in the .jwt attribute
1 parent 429d0c5 commit 8d827a2

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
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[verified_claim_name("id_token")] = idt
315+
msg["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[verified_claim_name("request")] = oidr
462+
self["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: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
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
1413
from ..oidc import IdToken
1514
from ..oidc import ID_TOKEN_VERIFY_ARGS
1615
from ..oidc import MessageWithIdToken
@@ -66,7 +65,7 @@ def verify(self, **kwargs):
6665
return False
6766

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

7170
return True
7271

@@ -167,7 +166,7 @@ def verify(self, **kwargs):
167166
if not idt.verify(**kwargs):
168167
return False
169168

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

173172
return True

tests/test_6_oidc.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
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
5453
from oidcmsg.time_util import utc_time_sans_frac
5554

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

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

856855

857856
def test_c_hash():
@@ -880,7 +879,7 @@ def test_c_hash():
880879

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

885884

886885
def test_missing_c_hash():

tests/test_7_session.py

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

1111
from oidcmsg.exception import MessageException
1212
from oidcmsg.exception import NotForMe
13-
from oidcmsg.oidc import verified_claim_name
1413
from oidcmsg.oidc import Claims
1514
from oidcmsg.oidc import ClaimsRequest
1615
from oidcmsg.oidc import IdToken
17-
from oidcmsg.oidc.session import BACK_CHANNEL_LOGOUT_EVENT, \
18-
BackChannelLogoutRequest
16+
from oidcmsg.oidc.session import BACK_CHANNEL_LOGOUT_EVENT
17+
from oidcmsg.oidc.session import BackChannelLogoutRequest
1918
from oidcmsg.oidc.session import LogoutToken
2019
from oidcmsg.oidc.session import CheckSessionRequest
2120
from oidcmsg.oidc.session import EndSessionRequest
@@ -81,11 +80,9 @@ def test_example(self):
8180
keyjar.add_symmetric(CLIENT_ID, _key.key)
8281
request.verify(keyjar=keyjar)
8382
assert isinstance(request, EndSessionRequest)
84-
assert set(request.keys()) == {verified_claim_name('id_token_hint'),
85-
'id_token_hint', 'redirect_url', 'state'}
83+
assert set(request.keys()) == {'id_token_hint', 'redirect_url', 'state'}
8684
assert request["state"] == "state0"
87-
assert request[
88-
verified_claim_name("id_token_hint")]["aud"] == ["client_1"]
85+
assert request["id_token_hint"]["aud"] == ["client_1"]
8986

9087

9188
class TestCheckSessionRequest(object):

0 commit comments

Comments
 (0)