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

utcnow plus configuration attribute additions. #55

Merged
merged 10 commits into from
Dec 14, 2021
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def run_tests(self):
"Programming Language :: Python :: 3.8",
"Topic :: Software Development :: Libraries :: Python Modules"],
install_requires=[
"cryptojwt>=1.5.2",
"cryptojwt==1.6.1",
"pyOpenSSL",
"filelock>=3.0.12",
'pyyaml>=5.1.2'
Expand Down
2 changes: 1 addition & 1 deletion src/oidcmsg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__author__ = "Roland Hedberg"
__version__ = "1.5.2"
__version__ = "1.5.4"

import os
from typing import Dict
Expand Down
2 changes: 1 addition & 1 deletion src/oidcmsg/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from oidcmsg.logging import configure_logging
from oidcmsg.util import load_yaml_config

DEFAULT_FILE_ATTRIBUTE_NAMES = ['server_key', 'server_cert', 'filename',
DEFAULT_FILE_ATTRIBUTE_NAMES = ['server_key', 'server_cert', 'filename', 'template_dir',
'private_path', 'public_path', 'db_file', 'jwks_file']

DEFAULT_DIR_ATTRIBUTE_NAMES = ['template_dir']
Expand Down
3 changes: 3 additions & 0 deletions src/oidcmsg/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def _keyjar(self, keyjar=None, conf=None, entity_id=""):
if "keys" in conf:
keys_args = {k: v for k, v in conf["keys"].items() if k != "uri_path"}
_keyjar = init_key_jar(**keys_args)
elif "key_conf" in conf:
keys_args = {k: v for k, v in conf["key_conf"].items() if k != "uri_path"}
_keyjar = init_key_jar(**keys_args)
else:
_keyjar = KeyJar()
if "jwks" in conf:
Expand Down
18 changes: 10 additions & 8 deletions src/oidcmsg/time_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Implements some usefull functions when dealing with validity of
Implements some useful functions when dealing with validity of
different types of information.
"""

import calendar
from datetime import datetime
from datetime import timedelta
from datetime import timezone
import logging
import re
import sys
import time
from datetime import datetime
from datetime import timedelta

TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
TIME_FORMAT_WITH_FRAGMENT = re.compile("^(\d{4,4}-\d{2,2}-\d{2,2}T\d{2,2}:\d{2,2}:\d{2,2})\.\d*Z$")
Expand Down Expand Up @@ -181,7 +181,8 @@ def time_in_a_while(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0
:return: datetime instance using UTC time
"""
delta = timedelta(days, seconds, microseconds, milliseconds, minutes, hours, weeks)
return datetime.utcnow() + delta
res = datetime.now(timezone.utc) + delta
return res.replace(tzinfo=None)


def time_a_while_ago(
Expand All @@ -200,7 +201,8 @@ def time_a_while_ago(
:return: datetime instance using UTC time
"""
delta = timedelta(days, seconds, microseconds, milliseconds, minutes, hours, weeks)
return datetime.utcnow() - delta
res = datetime.now(timezone.utc) - delta
return res.replace(tzinfo=None)


def in_a_while(
Expand Down Expand Up @@ -350,8 +352,8 @@ def later_than(after, before):
return after >= before


def utc_time_sans_frac():
now_timestampt = int(datetime.utcnow().timestamp())
def utc_time_sans_frac(): # MUST be the same as utc_time_sans_frac in cryptojwt
now_timestampt = int(datetime.now(timezone.utc).timestamp())
return now_timestampt


Expand Down
2 changes: 1 addition & 1 deletion tests/test_03_time_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# !/usr/bin/env python
#!/usr/bin/env python3

# pylint: disable=missing-docstring

Expand Down