diff --git a/alohomora/__init__.py b/alohomora/__init__.py index 58073cb..f753d15 100644 --- a/alohomora/__init__.py +++ b/alohomora/__init__.py @@ -16,10 +16,10 @@ import sys -__version__ = '3.1.0' +__version__ = '3.1.1' __author__ = 'Viasat' __author_email__ = 'vice-support@viasat.com' -__license__ = '(c) 2022 Viasat, Inc. See the LICENSE file for more details.' +__license__ = '(c) 2024 Viasat, Inc. See the LICENSE file for more details.' __url__ = 'https://github.com/Viasat/alohomora' __description__ = 'Get AWS API keys for a SAML-federated identity' diff --git a/alohomora/req.py b/alohomora/req.py index 4060a08..54aef8e 100644 --- a/alohomora/req.py +++ b/alohomora/req.py @@ -22,6 +22,7 @@ import time import os import base64 +from datetime import datetime, timedelta from http.cookiejar import LWPCookieJar try: @@ -806,6 +807,15 @@ def _make_request(self, url, func, data=None, headers=None, soup=True): LOG.debug("Post cookie jar: %s", self.session.cookies) LOG.debug("Request headers: %s", response.request.headers) LOG.debug("Response headers: %s", response.headers) + # On Windows the python builtin cookiejar chokes on a returned timestamp + # in the DUO status cookie. It is set to expire far in the future in the + # year 9999. Windows can not parse this timestamp, so we overwite it with + # an expiration 30 days in the future so it is parsable in Windows. + future_ts = (datetime.now() + timedelta(days=30)).timestamp() + for cookie in self.session.cookies: + if cookie.expires and cookie.expires > future_ts: + LOG.debug(f"rewrite coookie expires from: {cookie.expires} to: {future_ts}") + cookie.expires = future_ts self.session.cookies.save(ignore_discard=True, ignore_expires=True) if soup: the_soup = BeautifulSoup(response.text, 'html.parser')