|
1 | 1 | """
|
2 | 2 | OIDC/OAuth2 backend module.
|
3 | 3 | """
|
4 |
| -from datetime import datetime |
| 4 | +import datetime |
5 | 5 | import logging
|
6 | 6 | from urllib.parse import urlparse
|
7 | 7 |
|
|
16 | 16 | from ..exception import SATOSAError
|
17 | 17 | from ..response import Redirect
|
18 | 18 |
|
| 19 | + |
| 20 | +UTC = datetime.timezone.utc |
19 | 21 | logger = logging.getLogger(__name__)
|
20 | 22 |
|
21 | 23 |
|
@@ -121,9 +123,15 @@ def _translate_response(self, response, issuer):
|
121 | 123 | :param subject_type: public or pairwise according to oidc standard.
|
122 | 124 | :return: A SATOSA internal response.
|
123 | 125 | """
|
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) |
127 | 135 |
|
128 | 136 | internal_resp = InternalData(auth_info=auth_info)
|
129 | 137 | internal_resp.attributes = self.converter.to_internal("openid", response)
|
|
0 commit comments