Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fixed JWT expired token being logged as unhandled error
Mikail KOCAKb84a11375d85
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 973d74e93a..3055f6760a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -3,6 +3,7 @@All notable, unreleased changes to this project will be documented in this file. For the released changes, please visit the [Releases](https://github.com/mirumee/saleor/releases) page.## [Unreleased]+- Fixed JWT expired token being flagged as unhandled error rather than handled. - #5603 by @NyanKiyoshi## 2.10.0diff --git a/saleor/graphql/views.py b/saleor/graphql/views.pyindex 3372837b26..0d5d77ea29 100644--- a/saleor/graphql/views.py+++ b/saleor/graphql/views.py@@ -22,7 +22,7 @@ from graphql.error import (format_error as format_graphql_error,)from graphql.execution import ExecutionResult-from graphql_jwt.exceptions import PermissionDenied+from graphql_jwt.exceptions import JSONWebTokenErrorfrom ..core.utils import is_valid_ipv4, is_valid_ipv6@@ -58,7 +58,7 @@ class GraphQLView(View):middleware = Noneroot_value = None- HANDLED_EXCEPTIONS = (GraphQLError, PermissionDenied)+ HANDLED_EXCEPTIONS = (GraphQLError, JSONWebTokenError)def __init__(self, schema=None, executor=None, middleware=None, root_value=None, backend=Nonediff --git a/saleor/settings.py b/saleor/settings.pyindex fcf8315217..f12f33b745 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -1,6 +1,7 @@import astimport os.pathimport warnings+from datetime import timedeltaimport dj_database_urlimport dj_email_url@@ -473,9 +474,12 @@ AUTHENTICATION_BACKENDS = [# Django GraphQL JWT settingsGRAPHQL_JWT = {"JWT_PAYLOAD_HANDLER": "saleor.graphql.utils.create_jwt_payload",+ # How long until a token expires, default is 5m from graphql_jwt.settings+ "JWT_EXPIRATION_DELTA": timedelta(minutes=5),+ # Whether the JWT tokens should expire or not+ # Enabled by default in production mode; disabled in development mode by default+ "JWT_VERIFY_EXPIRATION": get_bool_from_env("JWT_VERIFY_EXPIRATION", not DEBUG),}-if not DEBUG:- GRAPHQL_JWT["JWT_VERIFY_EXPIRATION"] = True # type: ignore# CELERY SETTINGSCELERY_BROKER_URL = (