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

Commit

Permalink
For debugging purpose nice to know what was put in the ID Token and a…
Browse files Browse the repository at this point in the history
…lso what was in a received ID Token.
  • Loading branch information
rohe committed Jul 8, 2021
1 parent 07ad50d commit 6dd6b4b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions example/flask_op/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def _add_cookie(resp, cookie_spec):
for k,v in cookie_spec.items()
if k not in ('name',)}
kwargs["path"] = "/"
kwargs["samesite"] = "Lax"
resp.set_cookie(cookie_spec["name"], **kwargs)


Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
oidcmsg>=1.3.0
oidcmsg>=1.4.0
pyyaml
jinja2>=2.11.3
responses>=0.13.0
5 changes: 5 additions & 0 deletions src/oidcop/token/id_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def payload(
self, session_id, alg="RS256", code=None, access_token=None, extra_claims=None,
):
"""
Collect payload for the ID Token.
:param session_id: Session identifier
:param alg: Which signing algorithm to use for the IdToken
Expand Down Expand Up @@ -197,6 +198,8 @@ def payload(
except KeyError:
pass

logger.debug(f"Constructed ID Token payload: {_args}")

return _args

def sign_encrypt(
Expand Down Expand Up @@ -297,6 +300,8 @@ def info(self, token):
except JWSException:
raise UnknownToken()

logger.debug(f"Received ID Token payload: {_payload}")

if is_expired(_payload["exp"]):
raise ToOld("Token has expired")
# All the token metadata
Expand Down
17 changes: 17 additions & 0 deletions tests/test_05_id_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,3 +609,20 @@ def test_id_token_acr_claim(self):
_jwt = factory(id_token.value)
_id_token_content = _jwt.jwt.payload()
assert _id_token_content["acr"] == "https://refeds.org/profile/mfa"

def test_id_token_acr_none(self):
_req = AREQS.copy()
_req["claims"] = {"id_token": {"acr": None}}

session_id = self._create_session(_req,authn_info="https://refeds.org/profile/mfa")
grant = self.session_manager[session_id]
code = self._mint_code(grant, session_id)
access_token = self._mint_access_token(grant, session_id, code)

id_token = self._mint_id_token(
grant, session_id, token_ref=code, access_token=access_token.value
)

_jwt = factory(id_token.value)
_id_token_content = _jwt.jwt.payload()
assert _id_token_content["acr"] == "https://refeds.org/profile/mfa"

0 comments on commit 6dd6b4b

Please sign in to comment.