From c9186b5382f0e733e46391425b191098e5085711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Voron?= Date: Tue, 18 Oct 2022 08:36:01 +0200 Subject: [PATCH] Fix typing of samesite paramater in CookieTransport --- fastapi_users/authentication/transport/cookie.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fastapi_users/authentication/transport/cookie.py b/fastapi_users/authentication/transport/cookie.py index 6fa8e198..edc07aa9 100644 --- a/fastapi_users/authentication/transport/cookie.py +++ b/fastapi_users/authentication/transport/cookie.py @@ -1,5 +1,11 @@ +import sys from typing import Any, Optional +if sys.version_info < (3, 8): + from typing_extensions import Literal # pragma: no cover +else: + from typing import Literal # pragma: no cover + from fastapi import Response, status from fastapi.security import APIKeyCookie @@ -18,7 +24,7 @@ class CookieTransport(Transport): cookie_domain: Optional[str] = None, cookie_secure: bool = True, cookie_httponly: bool = True, - cookie_samesite: str = "lax", + cookie_samesite: Literal["lax", "strict", "none"] = "lax", ): self.cookie_name = cookie_name self.cookie_max_age = cookie_max_age