Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Mark X- headers as deprecated. Add headers without prefix (#8205)
L3str4nge155858de3f06
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f616ef2533..03f27d06ca 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -20,6 +20,11 @@ All notable, unreleased changes to this project will be documented in this file.# 3.0.0 [Unreleased]- Improve draft orders and orders webhooks - #SALEOR-4008 by @jakubkuc+- Mark `X-` headers as deprecated and add headers without prefix. All deprecated headers will be removed in Saleor 4.0 - #8179 by @L3str4nge+ * X-Saleor-Event -> Saleor-Event+ * X-Saleor-Domain -> Saleor-Domain+ * X-Saleor-Signature -> Saleor-Signature+ * X-Saleor-HMAC-SHA256 -> Saleor-HMAC-SHA256- Extend editorjs validator to accept blocks different than text - #SALEOR-3354 by @mociepka- Add query contains only schema validation - #6827 by @fowczarek- Add introspection caching - #6871 by @fowczarekdiff --git a/saleor/app/installation_utils.py b/saleor/app/installation_utils.pyindex ec08515a7b..de720795a1 100644--- a/saleor/app/installation_utils.py+++ b/saleor/app/installation_utils.py@@ -11,7 +11,12 @@ REQUEST_TIMEOUT = 25def send_app_token(target_url: str, token: str):domain = Site.objects.get_current().domain- headers = {"x-saleor-domain": domain, "Content-Type": "application/json"}+ headers = {+ "Content-Type": "application/json",+ # X- headers will be deprecated in Saleor 4.0, proper headers are without X-+ "x-saleor-domain": domain,+ "saleor-domain": domain,+ }json_data = {"auth_token": token}response = requests.post(target_url, json=json_data, headers=headers, timeout=REQUEST_TIMEOUTdiff --git a/saleor/app/management/commands/create_app.py b/saleor/app/management/commands/create_app.pyindex dab5ae2974..1fdc4aa449 100644--- a/saleor/app/management/commands/create_app.py+++ b/saleor/app/management/commands/create_app.py@@ -40,7 +40,11 @@ class Command(BaseCommand):def send_app_data(self, target_url, data: Dict[str, Any]):domain = Site.objects.get_current().domain- headers = {"x-saleor-domain": domain}+ headers = {+ # X- headers will be deprecated in Saleor 4.0, proper headers are without X-+ "x-saleor-domain": domain,+ "saleor-domain": domain,+ }try:response = requests.post(target_url, json=data, headers=headers, timeout=15)except RequestException as e:diff --git a/saleor/app/tests/cassettes/test_creates_app_from_manifest.yaml b/saleor/app/tests/cassettes/test_creates_app_from_manifest.yamlindex fad50c61d0..2dc75e0ab0 100644--- a/saleor/app/tests/cassettes/test_creates_app_from_manifest.yaml+++ b/saleor/app/tests/cassettes/test_creates_app_from_manifest.yaml@@ -116,8 +116,12 @@ interactions:- application/jsonUser-Agent:- python-requests/2.23.0++ # X- headers will be deprecated in Saleor 4.0, proper headers are without X-x-saleor-domain:- mirumee.com+ saleor-domain:+ - mirumee.commethod: POSTuri: http://otherapp:3000/registerresponse:diff --git a/saleor/app/tests/cassettes/test_creates_app_from_manifest_activate_app.yaml b/saleor/app/tests/cassettes/test_creates_app_from_manifest_activate_app.yamlindex de982cff58..07ff9a6dce 100644--- a/saleor/app/tests/cassettes/test_creates_app_from_manifest_activate_app.yaml+++ b/saleor/app/tests/cassettes/test_creates_app_from_manifest_activate_app.yaml@@ -116,8 +116,12 @@ interactions:- application/jsonUser-Agent:- python-requests/2.23.0++ # X- headers will be deprecated in Saleor 4.0, proper headers are without X-x-saleor-domain:- mirumee.com+ saleor-domain:+ - mirumee.commethod: POSTuri: http://otherapp:3000/registerresponse:diff --git a/saleor/app/tests/cassettes/test_creates_app_from_manifest_app_has_all_required_permissions.yaml b/saleor/app/tests/cassettes/test_creates_app_from_manifest_app_has_all_required_permissions.yamlindex 011fb23b95..b079a7ef39 100644--- a/saleor/app/tests/cassettes/test_creates_app_from_manifest_app_has_all_required_permissions.yaml+++ b/saleor/app/tests/cassettes/test_creates_app_from_manifest_app_has_all_required_permissions.yaml@@ -116,8 +116,12 @@ interactions:- application/jsonUser-Agent:- python-requests/2.23.0++ # X- headers will be deprecated in Saleor 4.0, proper headers are without X-x-saleor-domain:- mirumee.com+ saleor-domain:+ - mirumee.commethod: POSTuri: http://localhost:3000/registerresponse:diff --git a/saleor/app/tests/cassettes/test_install_app_task.yaml b/saleor/app/tests/cassettes/test_install_app_task.yamlindex ca5570ee68..931124f9a1 100644--- a/saleor/app/tests/cassettes/test_install_app_task.yaml+++ b/saleor/app/tests/cassettes/test_install_app_task.yaml@@ -65,8 +65,12 @@ interactions:- application/jsonUser-Agent:- python-requests/2.23.0++ # X- headers will be deprecated in Saleor 4.0, proper headers are without X-x-saleor-domain:- mirumee.com+ saleor-domain:+ - mirumee.commethod: POSTuri: http://localhost:3000/registerresponse:diff --git a/saleor/app/tests/test_app_commands.py b/saleor/app/tests/test_app_commands.pyindex 28652ab18b..f9e454c050 100644--- a/saleor/app/tests/test_app_commands.py+++ b/saleor/app/tests/test_app_commands.py@@ -59,7 +59,12 @@ def test_creates_app_from_manifest_sends_token(monkeypatch):token = app.tokens.all()[0].auth_tokenmocked_post.assert_called_once_with("http://localhost:3000/register",- headers={"Content-Type": "application/json", "x-saleor-domain": "mirumee.com"},+ headers={+ "Content-Type": "application/json",+ # X- headers will be deprecated in Saleor 4.0, proper headers are without X-+ "x-saleor-domain": "mirumee.com",+ "saleor-domain": "mirumee.com",+ },json={"auth_token": token},timeout=ANY,)@@ -119,7 +124,11 @@ def test_sends_data_to_target_url(monkeypatch):token = app.tokens.all()[0].auth_tokenmocked_post.assert_called_once_with(target_url,- headers={"x-saleor-domain": "mirumee.com"},+ headers={+ # X- headers will be deprecated in Saleor 4.0, proper headers are without X-+ "x-saleor-domain": "mirumee.com",+ "saleor-domain": "mirumee.com",+ },json={"auth_token": token},timeout=ANY,)diff --git a/saleor/plugins/webhook/tasks.py b/saleor/plugins/webhook/tasks.pyindex 542619ba22..64a9a691f1 100644--- a/saleor/plugins/webhook/tasks.py+++ b/saleor/plugins/webhook/tasks.py@@ -84,9 +84,13 @@ def send_webhook_using_http():headers = {"Content-Type": "application/json",+ # X- headers will be deprecated in Saleor 4.0, proper headers are without X-"X-Saleor-Event": event_type,"X-Saleor-Domain": domain,"X-Saleor-Signature": signature,+ "Saleor-Event": event_type,+ "Saleor-Domain": domain,+ "Saleor-Signature": signature,}response = requests.post(target_url, data=message, headers=headers, timeout=timeout)diff --git a/saleor/plugins/webhook/tests/cassettes/test_trigger_webhooks_with_http.yaml b/saleor/plugins/webhook/tests/cassettes/test_trigger_webhooks_with_http.yamlindex ede1e07424..0d57522a4d 100644--- a/saleor/plugins/webhook/tests/cassettes/test_trigger_webhooks_with_http.yaml+++ b/saleor/plugins/webhook/tests/cassettes/test_trigger_webhooks_with_http.yaml@@ -23,12 +23,20 @@ interactions:- application/jsonUser-Agent:- python-requests/2.24.0++ # X- headers will be deprecated in Saleor 4.0, proper headers are without X-X-Saleor-Domain:- mirumee.comX-Saleor-Event:- order_createdX-Saleor-Signature:- ''+ Saleor-Domain:+ - mirumee.com+ Saleor-Event:+ - order_created+ Saleor-Signature:+ - ''method: POSTuri: https://webhook.site/48978b64-4efb-43d5-a334-451a1d164009response:diff --git a/saleor/plugins/webhook/tests/cassettes/test_trigger_webhooks_with_http_and_secret_key.yaml b/saleor/plugins/webhook/tests/cassettes/test_trigger_webhooks_with_http_and_secret_key.yamlindex cdd096f049..7620b433e5 100644--- a/saleor/plugins/webhook/tests/cassettes/test_trigger_webhooks_with_http_and_secret_key.yaml+++ b/saleor/plugins/webhook/tests/cassettes/test_trigger_webhooks_with_http_and_secret_key.yaml@@ -23,6 +23,8 @@ interactions:- application/jsonUser-Agent:- python-requests/2.24.0++ # X- headers will be deprecated in Saleor 4.0, proper headers are without X-X-Saleor-Domain:- mirumee.comX-Saleor-Event:@@ -31,6 +33,14 @@ interactions:- sha1=cce609bb36a9aa6b54af010a2aef40979ddd56a309590a470a9c4602226324b4X-Saleor-Signature:- cce609bb36a9aa6b54af010a2aef40979ddd56a309590a470a9c4602226324b4+ Saleor-Domain:+ - mirumee.com+ Saleor-Event:+ - order_created+ Saleor-HMAC-SHA256:+ - sha1=cce609bb36a9aa6b54af010a2aef40979ddd56a309590a470a9c4602226324b4+ Saleor-Signature:+ - cce609bb36a9aa6b54af010a2aef40979ddd56a309590a470a9c4602226324b4method: POSTuri: https://webhook.site/48978b64-4efb-43d5-a334-451a1d164009response:diff --git a/saleor/plugins/webhook/tests/test_webhook_protocols.py b/saleor/plugins/webhook/tests/test_webhook_protocols.pyindex dcd207e0fa..99d9d65c82 100644--- a/saleor/plugins/webhook/tests/test_webhook_protocols.py+++ b/saleor/plugins/webhook/tests/test_webhook_protocols.py@@ -200,9 +200,13 @@ def test_trigger_webhooks_with_http(expected_headers = {"Content-Type": "application/json",+ # X- headers will be deprecated in Saleor 4.0, proper headers are without X-"X-Saleor-Event": "order_created","X-Saleor-Domain": "mirumee.com","X-Saleor-Signature": "",+ "Saleor-Event": "order_created",+ "Saleor-Domain": "mirumee.com",+ "Saleor-Signature": "",}mock_request.assert_called_once_with(@@ -231,9 +235,13 @@ def test_trigger_webhooks_with_http_and_secret_key()expected_headers = {"Content-Type": "application/json",+ # X- headers will be deprecated in Saleor 4.0, proper headers are without X-"X-Saleor-Event": "order_created","X-Saleor-Domain": "mirumee.com","X-Saleor-Signature": expected_signature,+ "Saleor-Event": "order_created",+ "Saleor-Domain": "mirumee.com",+ "Saleor-Signature": expected_signature,}mock_request.assert_called_once_with(