Skip to content

Commit a8a446a

Browse files
committed
Prepare the right datetime format
1 parent 34d8597 commit a8a446a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/satosa/backends/idpy_oidc.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
OIDC/OAuth2 backend module.
33
"""
4-
from datetime import datetime
4+
import datetime
55
import logging
66
from urllib.parse import urlparse
77

@@ -16,6 +16,8 @@
1616
from ..exception import SATOSAError
1717
from ..response import Redirect
1818

19+
20+
UTC = datetime.timezone.utc
1921
logger = logging.getLogger(__name__)
2022

2123

@@ -121,9 +123,15 @@ def _translate_response(self, response, issuer):
121123
:param subject_type: public or pairwise according to oidc standard.
122124
:return: A SATOSA internal response.
123125
"""
124-
timestamp = response["auth_time"]
125-
auth_class_ref = response.get("amr", response.get("acr", UNSPECIFIED))
126-
auth_info = AuthenticationInformation(auth_class_ref, timestamp, issuer)
126+
timestamp_epoch = (
127+
response.get("auth_time")
128+
or response.get("iat")
129+
or int(datetime.datetime.now(UTC).timestamp())
130+
)
131+
timestamp_dt = datetime.datetime.fromtimestamp(timestamp_epoch, UTC)
132+
timestamp_iso = timestamp_dt.isoformat().replace("+00:00", "Z")
133+
auth_class_ref = response.get("acr") or response.get("amr") or UNSPECIFIED
134+
auth_info = AuthenticationInformation(auth_class_ref, timestamp_iso, issuer)
127135

128136
internal_resp = InternalData(auth_info=auth_info)
129137
internal_resp.attributes = self.converter.to_internal("openid", response)

0 commit comments

Comments
 (0)