diff --git a/blacksheep/client/cookies.py b/blacksheep/client/cookies.py index cc4beab3..a4bb6cec 100644 --- a/blacksheep/client/cookies.py +++ b/blacksheep/client/cookies.py @@ -1,5 +1,5 @@ import logging -from datetime import datetime, timedelta +from datetime import timedelta from ipaddress import ip_address from typing import Dict, Iterable, Optional, TypeVar diff --git a/blacksheep/server/authentication/cookie.py b/blacksheep/server/authentication/cookie.py index 2b43736c..408ad030 100644 --- a/blacksheep/server/authentication/cookie.py +++ b/blacksheep/server/authentication/cookie.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, UTC from typing import Any, Optional, Sequence from guardpost import AuthenticationHandler, Identity @@ -80,7 +80,9 @@ def set_cookie(self, data: Any, response: Response, secure: bool = False) -> Non path="/", http_only=True, secure=secure, - expires=datetime.fromtimestamp(data["exp"]) if "exp" in data else None, + expires=( + datetime.fromtimestamp(data["exp"], UTC) if "exp" in data else None + ), ) ) diff --git a/blacksheep/server/openapi/common.py b/blacksheep/server/openapi/common.py index 2fde0283..2b73269e 100644 --- a/blacksheep/server/openapi/common.py +++ b/blacksheep/server/openapi/common.py @@ -9,7 +9,6 @@ import json from abc import ABC, abstractmethod from dataclasses import dataclass -from datetime import datetime from enum import Enum from http import HTTPStatus from typing import ( diff --git a/blacksheep/server/openapi/ui.py b/blacksheep/server/openapi/ui.py index a03ce6a8..c713694c 100644 --- a/blacksheep/server/openapi/ui.py +++ b/blacksheep/server/openapi/ui.py @@ -1,6 +1,5 @@ from abc import ABC, abstractmethod from dataclasses import dataclass -from datetime import datetime from typing import Callable from blacksheep.messages import Request, Response diff --git a/tests/client/test_cookiejar.py b/tests/client/test_cookiejar.py index 738992e8..dae36601 100644 --- a/tests/client/test_cookiejar.py +++ b/tests/client/test_cookiejar.py @@ -1,4 +1,4 @@ -from datetime import datetime, timedelta +from datetime import timedelta from blacksheep.utils.time import utcnow