From 773f378e1d9a6f6dec9bbffd31a90e7c41dccf56 Mon Sep 17 00:00:00 2001 From: Stijn Date: Mon, 31 Jan 2022 18:07:35 +0100 Subject: [PATCH] Add JWT_COOKIE_SAMESITE property to deleted cookie --- graphql_jwt/utils.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/graphql_jwt/utils.py b/graphql_jwt/utils.py index aff19515..66647739 100644 --- a/graphql_jwt/utils.py +++ b/graphql_jwt/utils.py @@ -137,8 +137,11 @@ def set_cookie(response, key, value, expires): def delete_cookie(response, key): - response.delete_cookie( - key, - path=jwt_settings.JWT_COOKIE_PATH, - domain=jwt_settings.JWT_COOKIE_DOMAIN, - ) + kwargs = { + "path": jwt_settings.JWT_COOKIE_PATH, + "domain": jwt_settings.JWT_COOKIE_DOMAIN, + } + if django.VERSION >= (2, 1): + kwargs["samesite"] = jwt_settings.JWT_COOKIE_SAMESITE + + response.delete_cookie(key, **kwargs)