Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Drop JWT_TOKEN_SECRET in favor of settings.SECRET_KEY
Marcin Gębala14aacde33956
diff --git a/common.env b/common.envindex c6172fe307..69f808b8b1 100644--- a/common.env+++ b/common.env@@ -3,5 +3,4 @@ [email protected]OPENEXCHANGERATES_API_KEYCELERY_BROKER_URL=redis://redis:6379/1SECRET_KEY=changeme-JWT_VERIFY_EXPIRATION=TrueVATLAYER_ACCESS_KEYdiff --git a/saleor/account/utils.py b/saleor/account/utils.pyindex a3fec1faea..79470405ae 100644--- a/saleor/account/utils.py+++ b/saleor/account/utils.py@@ -100,16 +100,14 @@ def create_jwt_token(token_data):expiration_date = timezone.now() + timezone.timedelta(hours=1)token_kwargs = {"exp": expiration_date}token_kwargs.update(token_data)- token = jwt.encode(- token_kwargs, settings.JWT_TOKEN_SECRET, algorithm="HS256"- ).decode()+ token = jwt.encode(token_kwargs, settings.SECRET_KEY, algorithm="HS256").decode()return tokendef decode_jwt_token(token):try:decoded_token = jwt.decode(- token.encode(), settings.JWT_TOKEN_SECRET, algorithms=["HS256"]+ token.encode(), settings.SECRET_KEY, algorithms=["HS256"])except jwt.PyJWTError:raise ValidationError(diff --git a/saleor/settings.py b/saleor/settings.pyindex 6ead826967..e230651b59 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -464,8 +464,12 @@ AUTHENTICATION_BACKENDS = ["django.contrib.auth.backends.ModelBackend",]--GRAPHQL_JWT = {"JWT_PAYLOAD_HANDLER": "saleor.graphql.utils.create_jwt_payload"}+# Django GraphQL JWT settings+GRAPHQL_JWT = {+ "JWT_PAYLOAD_HANDLER": "saleor.graphql.utils.create_jwt_payload",+}+if not DEBUG:+ GRAPHQL_JWT["JWT_VERIFY_EXPIRATION"] = True # type: ignore# CELERY SETTINGSCELERY_BROKER_URL = (@@ -539,10 +543,6 @@ PLUGINS = [# True to use DraftJS (JSON based), for the 2.0 dashboard# False to use the old editor from dashboard 1.0USE_JSON_CONTENT = get_bool_from_env("USE_JSON_CONTENT", False)-JWT_TOKEN_SECRET = os.environ.get("JWT_TOKEN_SECRET", "saleor")-if not DEBUG:- JWT_VERIFY_EXPIRATION = True-if (not DEBUG