Skip to content

Commit

Permalink
Unbind authentication event lifetime from userinfo response
Browse files Browse the repository at this point in the history
Signed-off-by: Kostis Triantafyllakis <[email protected]>
  • Loading branch information
ctriant authored and lionick committed Nov 7, 2024
1 parent a78dabe commit e631fc3
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions src/idpyoidc/server/oidc/userinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ def do_response(
client_id: Optional[str] = "",
**kwargs,
) -> dict:

if "error" in kwargs and kwargs["error"]:
return Endpoint.do_response(self, response_args, request, **kwargs)

Expand Down Expand Up @@ -135,35 +134,16 @@ def process_request(self, request=None, **kwargs):
if token.is_active() is False:
return self.error_cls(error="invalid_token", error_description="Invalid Token")

allowed = True
_auth_event = _grant.authentication_event
# if the authentication is still active or offline_access is granted.
if not _auth_event["valid_until"] >= utc_time_sans_frac():
logger.debug(
"authentication not valid: {} > {}".format(
datetime.fromtimestamp(_auth_event["valid_until"]),
datetime.fromtimestamp(utc_time_sans_frac()),
)
)
allowed = False

# This has to be made more finegrained.
# if "offline_access" in session["authn_req"]["scope"]:
# pass

_cntxt = self.upstream_get("context")
if allowed:
_claims_restriction = _cntxt.claims_interface.get_claims(
_session_info["branch_id"], scopes=token.scope, claims_release_point="userinfo"
)
info = _cntxt.claims_interface.get_user_claims(
_session_info["user_id"],
claims_restriction=_claims_restriction,
client_id=_session_info["client_id"]
)
info["sub"] = _grant.sub
if _grant.add_acr_value("userinfo"):
info["acr"] = _grant.authentication_event["authn_info"]
_claims_restriction = _cntxt.claims_interface.get_claims(
_session_info["branch_id"], scopes=token.scope, claims_release_point="userinfo"
)
info = _cntxt.claims_interface.get_user_claims(
_session_info["user_id"], claims_restriction=_claims_restriction
)
info["sub"] = _grant.sub
if _grant.add_acr_value("userinfo"):
info["acr"] = _grant.authentication_event["authn_info"]

extra_claims = kwargs.get("extra_claims")
if extra_claims:
Expand Down Expand Up @@ -213,7 +193,7 @@ def parse_request(self, request, http_info=None, **kwargs):
def _enforce_policy(self, request, response_info, token, config):
policy = config["policy"]
callable = policy["function"]
kwargs = policy.get("kwargs", {})
kwargs = policy.get("kwargs") or {}

if isinstance(callable, str):
try:
Expand Down

0 comments on commit e631fc3

Please sign in to comment.