Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Update required permissions for attribute options (#9204)
Iga Karbowiakc7bce5430db1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex eb1370aeb4..3c3985ca33 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -57,6 +57,9 @@ unavailable - #8978 by @IKarbowiak- Add `SHIPPING_LIST_METHODS_FOR_CHECKOUT` sync webhook- Fix crash when Avalara plugin was used together with Webhooks plugin for shipping methods - #9121 by @rafalp- Allow fetching unpublished pages by app with manage pages permission - #9181 by @IKarbowiak+- Update required permissions for attribute options - #9204 by @IKarbowiak+ - Product attribute options can be fetched by requestors with manage product types and attributes permission.+ - Page attribute options can be fetched by requestors with manage page types and attributes permission.# 3.0.0diff --git a/saleor/graphql/decorators.py b/saleor/graphql/decorators.pyindex 586be79a23..7f906f900e 100644--- a/saleor/graphql/decorators.py+++ b/saleor/graphql/decorators.py@@ -8,7 +8,9 @@ from ..attribute import AttributeTypefrom ..core.exceptions import PermissionDeniedfrom ..core.permissions import (PagePermissions,+ PageTypePermissions,ProductPermissions,+ ProductTypePermissions,has_one_of_permissions,)from ..core.permissions import permission_required as core_permission_required@@ -100,9 +102,19 @@ def check_attribute_required_permissions():def check_perms(context, attribute):requestor = get_user_or_app_from_context(context)if attribute.type == AttributeType.PAGE_TYPE:- return core_permission_required((PagePermissions.MANAGE_PAGES,), requestor)- return core_permission_required(- (ProductPermissions.MANAGE_PRODUCTS,), requestor+ return has_one_of_permissions(+ requestor,+ (+ PagePermissions.MANAGE_PAGES,+ PageTypePermissions.MANAGE_PAGE_TYPES_AND_ATTRIBUTES,+ ),+ )+ return has_one_of_permissions(+ requestor,+ (+ ProductPermissions.MANAGE_PRODUCTS,+ ProductTypePermissions.MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES,+ ),)return account_passes_test_for_attribute(check_perms)diff --git a/saleor/graphql/page/tests/mutations/test_page_attribute_assign.py b/saleor/graphql/page/tests/mutations/test_page_attribute_assign.pyindex a8449f7c08..cc4397057f 100644--- a/saleor/graphql/page/tests/mutations/test_page_attribute_assign.py+++ b/saleor/graphql/page/tests/mutations/test_page_attribute_assign.py@@ -18,6 +18,12 @@ PAGE_ASSIGN_ATTR_QUERY = """idattributes {id+ visibleInStorefront+ filterableInDashboard+ filterableInStorefront+ availableInGrid+ valueRequired+ storefrontSearchPosition}}}diff --git a/saleor/graphql/product/tests/test_attributes.py b/saleor/graphql/product/tests/test_attributes.pyindex 64b483476c..871bd03691 100644--- a/saleor/graphql/product/tests/test_attributes.py+++ b/saleor/graphql/product/tests/test_attributes.py@@ -280,9 +280,18 @@ PRODUCT_ASSIGN_ATTR_QUERY = """idproductAttributes {id+ visibleInStorefront+ filterableInDashboard+ filterableInStorefront}variantAttributes {id+ visibleInStorefront+ filterableInDashboard+ filterableInStorefront+ availableInGrid+ valueRequired+ storefrontSearchPosition}}}