You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2026/10/26 11:29:50 UTC
(ofbiz-framework) branch release24.09 updated (580ad3b618 -> 0a899c8bc0)
This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a change to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
from 580ad3b618 Remove unnecessary Dependabot configuration file from the release branch
new 27a350f839 Fixed: Add missing permission checks to product costing, catalog and shipment-method services (OFBIZ-13715)
new aceaba654a Adapt orderInventoryPermissionCheck to release24.09's Groovy helpers
new 0a899c8bc0 Run internal balanceInventoryItems and createCostComponent calls as the system user
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../jobshopmgt/ProductionRunServicesScript.groovy | 12 +++++-
.../jobshopmgt/ProductionRunServices.java | 44 ++++++++++++++++++++--
applications/order/servicedef/secas.xml | 2 +-
applications/product/servicedef/secas.xml | 6 +--
applications/product/servicedef/services.xml | 2 +
applications/product/servicedef/services_cost.xml | 6 +++
.../product/servicedef/services_facility.xml | 7 ++++
.../product/servicedef/services_pricepromo.xml | 3 ++
.../product/servicedef/services_shipment.xml | 6 +++
applications/product/servicedef/services_store.xml | 3 ++
.../inventory/InventoryServicesScript.groovy | 19 ++++++++++
.../shipment/ShipmentReceiptServices.groovy | 16 +++++---
12 files changed, 111 insertions(+), 15 deletions(-)
(ofbiz-framework) 02/03: Adapt orderInventoryPermissionCheck to release24.09's Groovy helpers
Posted by mr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
commit aceaba654a07f37c5d33206d51dcf344bb54842b
Author: Mridul Pathak <mr...@gmail.com>
AuthorDate: Thu Oct 22 22:27:35 2026 +0530
Adapt orderInventoryPermissionCheck to release24.09's Groovy helpers
release24.09's GroovyBaseScript doesn't have the require() helper or the
failure(resource, property) overload used on trunk; rewritten using the
same error()/success()/failure(message) style already used by the
sibling facilityGenericPermission in this file.
---
.../ofbiz/product/product/inventory/InventoryServicesScript.groovy | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/inventory/InventoryServicesScript.groovy b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/inventory/InventoryServicesScript.groovy
index ebe12f0de9..aca105414a 100644
--- a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/inventory/InventoryServicesScript.groovy
+++ b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/inventory/InventoryServicesScript.groovy
@@ -75,11 +75,14 @@ Map facilityGenericPermission() {
*/
Map orderInventoryPermissionCheck() {
String mainAction = parameters.mainAction
- require(mainAction as boolean, 'ProductUiLabels', 'ProductMissingMainActionInPermissionService')
+ if (!mainAction) {
+ return error(UtilProperties.getMessage('ProductUiLabels', 'ProductMissingMainActionInPermissionService', parameters.locale))
+ }
Map result = success()
result.hasPermission = security.hasEntityPermission('ORDERMGR', "_${mainAction}", parameters.userLogin)
if (!result.hasPermission) {
- result = failure('ProductUiLabels', 'ProductPermissionError')
+ result = failure(UtilProperties.getMessage('ProductUiLabels', 'ProductPermissionError', parameters.locale))
+ result.hasPermission = false
}
return result
}
(ofbiz-framework) 03/03: Run internal balanceInventoryItems and createCostComponent calls as the system user
Posted by mr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
commit 0a899c8bc0c1cb254c92c46a7a2e25b526ab5d45
Author: Mridul Pathak <mr...@gmail.com>
AuthorDate: Mon Oct 26 13:14:11 2026 +0530
Run internal balanceInventoryItems and createCostComponent calls as the system user
The permission checks this PR added to balanceInventoryItems, setOrderReservationPriority, and createCostComponent broke several internal callers that invoke these services as a trusted side effect of an already-permitted operation, none of which hold the staff-level permission these services now require.
- ProductionRunServices.java: 4 balanceInventoryItems calls and 5 createCostComponent calls, from production-run status-change and cost-calculation flows
- ProductionRunServicesScript.groovy: 2 balanceInventoryItems calls, from production-run task issuance
- ShipmentReceiptServices.groovy: 2 balanceInventoryItems calls, from shipment-receipt processing
- order/servicedef/secas.xml and product/servicedef/secas.xml: 4 ECA actions (storeOrder, createInventoryTransfer, updateInventoryTransfer, createPhysicalInventoryAndVariance) now run their balanceInventoryItems/setOrderReservationPriority action as the system user
Each caller now resolves the system UserLogin and runs that specific call under it, following the pattern already used elsewhere in the codebase for trusted internal side effects.
---
.../jobshopmgt/ProductionRunServicesScript.groovy | 12 +++++-
.../jobshopmgt/ProductionRunServices.java | 44 ++++++++++++++++++++--
applications/order/servicedef/secas.xml | 2 +-
applications/product/servicedef/secas.xml | 6 +--
.../shipment/ShipmentReceiptServices.groovy | 16 +++++---
5 files changed, 65 insertions(+), 15 deletions(-)
diff --git a/applications/manufacturing/src/main/groovy/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServicesScript.groovy b/applications/manufacturing/src/main/groovy/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServicesScript.groovy
index 80e4355eaf..cd04d0e6c0 100644
--- a/applications/manufacturing/src/main/groovy/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServicesScript.groovy
+++ b/applications/manufacturing/src/main/groovy/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServicesScript.groovy
@@ -223,7 +223,11 @@ Map issueProductionRunTaskComponent() {
quantityOnHandDiff: -parameters.quantityNotIssued,
reasonEnumId: parameters.reasonEnumId,
description: parameters.description]
- run service: 'balanceInventoryItems', with: [inventoryItemId: lastNonSerInventoryItem.inventoryItemId]
+ // balanceInventoryItems requires ORDERMGR_UPDATE; run as the "system" user since this is a trusted side
+ // effect of an already-permitted production-run operation
+ GenericValue balanceInventoryPermUserLogin = from('UserLogin').where(userLoginId: 'system').cache().queryOne()
+ run service: 'balanceInventoryItems', with: [inventoryItemId: lastNonSerInventoryItem.inventoryItemId,
+ userLogin: balanceInventoryPermUserLogin]
} else {
// no non-ser inv item, create a non-ser InventoryItem with availableToPromise = -quantityNotIssued
Map serviceResult = run service: 'createInventoryItem', with: [productId: productId,
@@ -311,7 +315,11 @@ Map issueProductionRunTaskComponentInline(Map parameters,
return serviceResult
}
parameters.quantityNotIssued -= parameters.deductAmount
- serviceResult = run service: 'balanceInventoryItems', with: [inventoryItemId: inventoryItem.inventoryItemId]
+ // balanceInventoryItems requires ORDERMGR_UPDATE; run as the "system" user since this is a trusted side
+ // effect of an already-permitted production-run operation
+ GenericValue balanceInventoryPermUserLogin = from('UserLogin').where(userLoginId: 'system').cache().queryOne()
+ serviceResult = run service: 'balanceInventoryItems', with: [inventoryItemId: inventoryItem.inventoryItemId,
+ userLogin: balanceInventoryPermUserLogin]
if (ServiceUtil.isError(serviceResult)) {
return serviceResult
}
diff --git a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
index 2f6942956c..c2330037ae 100644
--- a/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
+++ b/applications/manufacturing/src/main/java/org/apache/ofbiz/manufacturing/jobshopmgt/ProductionRunServices.java
@@ -1068,6 +1068,10 @@ public class ProductionRunServices {
inMap.put("costComponentTypeId", "ACTUAL_" + productCostComponentCalc.getString("costComponentTypeId"));
inMap.put("costUomId", partyAccountingPreference.get("baseCurrencyUomId"));
inMap.put("cost", productCostAdjustment);
+ // createCostComponent requires CATALOG_CREATE; run as the "system" user since this is a trusted side
+ // effect of an already-permitted production-run cost calculation
+ inMap.put("userLogin", EntityQuery.use(delegator).from("UserLogin")
+ .where("userLoginId", "system").cache().queryOne());
serviceResult = dispatcher.runSync("createCostComponent", inMap);
if (ServiceUtil.isError(serviceResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
@@ -1233,6 +1237,10 @@ public class ProductionRunServices {
inMap.put("costComponentCalcId", costComponentCalc.getString("costComponentCalcId"));
inMap.put("costUomId", costComponentCalc.getString("currencyUomId"));
inMap.put("cost", totalCost);
+ // createCostComponent requires CATALOG_CREATE; run as the "system" user since this is a trusted side
+ // effect of an already-permitted production-run cost calculation
+ inMap.put("userLogin", EntityQuery.use(delegator).from("UserLogin")
+ .where("userLoginId", "system").cache().queryOne());
serviceResult = dispatcher.runSync("createCostComponent", inMap);
if (ServiceUtil.isError(serviceResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
@@ -1280,6 +1288,10 @@ public class ProductionRunServices {
inMap.put("costUomId", currencyUomId);
inMap.put("cost", fixedAssetCost);
inMap.put("fixedAssetId", fixedAsset.get("fixedAssetId"));
+ // createCostComponent requires CATALOG_CREATE; run as the "system" user since this is a trusted side
+ // effect of an already-permitted production-run cost calculation
+ inMap.put("userLogin", EntityQuery.use(delegator).from("UserLogin")
+ .where("userLoginId", "system").cache().queryOne());
serviceResult = dispatcher.runSync("createCostComponent", inMap);
if (ServiceUtil.isError(serviceResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
@@ -1338,6 +1350,10 @@ public class ProductionRunServices {
inMap.put("costComponentTypeId", "ACTUAL_MAT_COST");
inMap.put("costUomId", currencyUomId);
inMap.put("cost", materialsCost);
+ // createCostComponent requires CATALOG_CREATE; run as the "system" user since this is a trusted side
+ // effect of an already-permitted production-run cost calculation
+ inMap.put("userLogin", EntityQuery.use(delegator).from("UserLogin")
+ .where("userLoginId", "system").cache().queryOne());
serviceResult = dispatcher.runSync("createCostComponent", inMap);
if (ServiceUtil.isError(serviceResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
@@ -1964,12 +1980,17 @@ public class ProductionRunServices {
serviceContext = new HashMap<>();
serviceContext.put("inventoryItemId", inventoryItemId);
serviceContext.put("userLogin", userLogin);
+ // balanceInventoryItems requires ORDERMGR_UPDATE; run as the "system" user since this is a trusted side
+ // effect of an already-permitted production-run operation
+ GenericValue balanceInventoryPermUserLogin = EntityQuery.use(delegator).from("UserLogin")
+ .where("userLoginId", "system").cache().queryOne();
+ serviceContext.put("userLogin", balanceInventoryPermUserLogin);
serviceResult = dispatcher.runSync("balanceInventoryItems", serviceContext);
if (ServiceUtil.isError(serviceResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
}
}
- } catch (GenericServiceException exc) {
+ } catch (GenericServiceException | GenericEntityException exc) {
return ServiceUtil.returnError(exc.getMessage());
}
} else {
@@ -2016,6 +2037,11 @@ public class ProductionRunServices {
serviceContext = new HashMap<>();
serviceContext.put("inventoryItemId", inventoryItemId);
serviceContext.put("userLogin", userLogin);
+ // balanceInventoryItems requires ORDERMGR_UPDATE; run as the "system" user since this is a trusted side
+ // effect of an already-permitted production-run operation
+ GenericValue balanceInventoryPermUserLogin = EntityQuery.use(delegator).from("UserLogin")
+ .where("userLoginId", "system").cache().queryOne();
+ serviceContext.put("userLogin", balanceInventoryPermUserLogin);
if (orderItem != null) {
// the reservations of this order item are privileged reservations
serviceContext.put("priorityOrderId", orderItem.getString("orderId"));
@@ -2025,7 +2051,7 @@ public class ProductionRunServices {
if (ServiceUtil.isError(serviceResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
}
- } catch (GenericServiceException exc) {
+ } catch (GenericServiceException | GenericEntityException exc) {
return ServiceUtil.returnError(exc.getMessage());
}
}
@@ -2197,12 +2223,17 @@ public class ProductionRunServices {
serviceContext = new HashMap<>();
serviceContext.put("inventoryItemId", inventoryItemId);
serviceContext.put("userLogin", userLogin);
+ // balanceInventoryItems requires ORDERMGR_UPDATE; run as the "system" user since this is a trusted side
+ // effect of an already-permitted production-run operation
+ GenericValue balanceInventoryPermUserLogin = EntityQuery.use(delegator).from("UserLogin")
+ .where("userLoginId", "system").cache().queryOne();
+ serviceContext.put("userLogin", balanceInventoryPermUserLogin);
serviceResult = dispatcher.runSync("balanceInventoryItems", serviceContext);
if (ServiceUtil.isError(serviceResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
}
}
- } catch (GenericServiceException exc) {
+ } catch (GenericServiceException | GenericEntityException exc) {
return ServiceUtil.returnError(exc.getMessage());
}
} else {
@@ -2250,11 +2281,16 @@ public class ProductionRunServices {
serviceContext = new HashMap<>();
serviceContext.put("inventoryItemId", inventoryItemId);
serviceContext.put("userLogin", userLogin);
+ // balanceInventoryItems requires ORDERMGR_UPDATE; run as the "system" user since this is a trusted side
+ // effect of an already-permitted production-run operation
+ GenericValue balanceInventoryPermUserLogin = EntityQuery.use(delegator).from("UserLogin")
+ .where("userLoginId", "system").cache().queryOne();
+ serviceContext.put("userLogin", balanceInventoryPermUserLogin);
serviceResult = dispatcher.runSync("balanceInventoryItems", serviceContext);
if (ServiceUtil.isError(serviceResult)) {
return ServiceUtil.returnError(ServiceUtil.getErrorMessage(serviceResult));
}
- } catch (GenericServiceException exc) {
+ } catch (GenericServiceException | GenericEntityException exc) {
return ServiceUtil.returnError(exc.getMessage());
}
}
diff --git a/applications/order/servicedef/secas.xml b/applications/order/servicedef/secas.xml
index ffbe2d67d5..c90cb114fd 100644
--- a/applications/order/servicedef/secas.xml
+++ b/applications/order/servicedef/secas.xml
@@ -39,7 +39,7 @@ under the License.
</eca>
<eca service="storeOrder" event="return">
- <action service="setOrderReservationPriority" mode="sync"/>
+ <action service="setOrderReservationPriority" mode="sync" run-as-user="system"/>
</eca>
<eca service="updateOrderItems" event="commit">
diff --git a/applications/product/servicedef/secas.xml b/applications/product/servicedef/secas.xml
index 2ca07b6ff5..afda290d2b 100644
--- a/applications/product/servicedef/secas.xml
+++ b/applications/product/servicedef/secas.xml
@@ -52,7 +52,7 @@ under the License.
<eca service="createInventoryTransfer" event="commit">
<condition field-name="statusId" operator="equals" value="IXF_COMPLETE"/>
<action service="completeInventoryTransfer" mode="sync"/>
- <action service="balanceInventoryItems" mode="sync"/>
+ <action service="balanceInventoryItems" mode="sync" run-as-user="system"/>
</eca>
<eca service="updateInventoryTransfer" event="invoke">
@@ -62,12 +62,12 @@ under the License.
<eca service="updateInventoryTransfer" event="commit">
<condition field-name="statusId" operator="equals" value="IXF_COMPLETE"/>
<action service="completeInventoryTransfer" mode="sync"/>
- <action service="balanceInventoryItems" mode="sync"/>
+ <action service="balanceInventoryItems" mode="sync" run-as-user="system"/>
</eca>
<!-- inventory variance -->
<eca service="createPhysicalInventoryAndVariance" event="commit">
- <action service="balanceInventoryItems" mode="sync"/>
+ <action service="balanceInventoryItems" mode="sync" run-as-user="system"/>
</eca>
<!-- inventory changes -->
diff --git a/applications/product/src/main/groovy/org/apache/ofbiz/product/shipment/ShipmentReceiptServices.groovy b/applications/product/src/main/groovy/org/apache/ofbiz/product/shipment/ShipmentReceiptServices.groovy
index c52882fae1..14387bd364 100644
--- a/applications/product/src/main/groovy/org/apache/ofbiz/product/shipment/ShipmentReceiptServices.groovy
+++ b/applications/product/src/main/groovy/org/apache/ofbiz/product/shipment/ShipmentReceiptServices.groovy
@@ -178,10 +178,13 @@ Map receiveInventoryProduct () {
}
}
if (parameters.quantityAccepted > BigDecimal.ZERO) {
- serviceInMap = [:]
- serviceInMap = parameters
- serviceInMap.inventoryItemId = currentInventoryItemId
- run service: 'balanceInventoryItems', with: serviceInMap
+ // balanceInventoryItems requires ORDERMGR_UPDATE; run as the "system" user since this is a trusted side effect of an
+ // already-permitted shipment-receipt operation. A copy (not an alias of parameters/serviceInMap) is used here so this
+ // elevation doesn't leak into later iterations' calls that reuse the shared parameters map.
+ Map balanceInventoryMap = new HashMap(parameters)
+ balanceInventoryMap.inventoryItemId = currentInventoryItemId
+ balanceInventoryMap.userLogin = from('UserLogin').where(userLoginId: 'system').cache().queryOne()
+ run service: 'balanceInventoryItems', with: balanceInventoryMap
successMessageList << "Received ${parameters.quantityAccepted} of ${parameters.productId}"
.concat(" in inventory item ${currentInventoryItemId}.") as String
@@ -397,8 +400,11 @@ Map cancelReceivedItems() {
run service: 'createInventoryItemDetail', with: inventoryItemDetailMap
// Balance the inventory item
+ // balanceInventoryItems requires ORDERMGR_UPDATE; run as the "system" user since this is a trusted side
+ // effect of an already-permitted shipment-receipt operation
Map balanceInventoryItemMap = [inventoryItemId: inventoryItem.inventoryItemId,
- priorityOrderId: shipmentReceipt.orderId, priorityOrderItemSeqId: shipmentReceipt.orderItemSeqId]
+ priorityOrderId: shipmentReceipt.orderId, priorityOrderItemSeqId: shipmentReceipt.orderItemSeqId,
+ userLogin: from('UserLogin').where(userLoginId: 'system').cache().queryOne()]
run service: 'balanceInventoryItems', with: balanceInventoryItemMap
// update the shipment status, if shipment was received
(ofbiz-framework) 01/03: Fixed: Add missing permission checks to product costing, catalog and shipment-method services (OFBIZ-13715)
Posted by mr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
mridulpathak pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
commit 27a350f8394730880e447323b542411e076a6d17
Author: Mridul Pathak <mr...@gmail.com>
AuthorDate: Thu Oct 22 22:17:43 2026 +0530
Fixed: Add missing permission checks to product costing, catalog and shipment-method services (OFBIZ-13715)
- CostComponent/ProductCostComponentCalc (create/update/delete), createProductPaymentMethodType, createProductGroupOrder, CarrierShipmentMethod (create/update), updateShipmentMethodType, removeShipmentEstimate and ShipmentTimeEstimate (update/expire) now require the existing productGenericPermission, matching the convention already used 38x elsewhere in services.xml.
- ProductStoreGroup (create/update) and createProductStoreGroupMember now require the existing productStoreGenericPermission, matching sibling store services.
- ProductPriceAction (create/update/delete) now require the existing productPriceGenericPermission, matching sibling createProductPriceRule/updateProductPriceRule.
- balanceInventoryItems and setOrderReservationPriority now require a new orderInventoryPermissionCheck, since no sibling in this order-management inventory-reservation cluster had any permission check to reuse.
---
applications/product/servicedef/services.xml | 2 ++
applications/product/servicedef/services_cost.xml | 6 ++++++
applications/product/servicedef/services_facility.xml | 7 +++++++
applications/product/servicedef/services_pricepromo.xml | 3 +++
applications/product/servicedef/services_shipment.xml | 6 ++++++
applications/product/servicedef/services_store.xml | 3 +++
.../product/inventory/InventoryServicesScript.groovy | 16 ++++++++++++++++
7 files changed, 43 insertions(+)
diff --git a/applications/product/servicedef/services.xml b/applications/product/servicedef/services.xml
index 6e141c2306..d1a94d6342 100644
--- a/applications/product/servicedef/services.xml
+++ b/applications/product/servicedef/services.xml
@@ -306,6 +306,7 @@ under the License.
<!-- Product PaymentMethodType Services -->
<service name="createProductPaymentMethodType" default-entity-name="ProductPaymentMethodType" engine="entity-auto" invoke="create" auth="true">
<description>Create an ProductPaymentMethodType</description>
+ <permission-service service-name="productGenericPermission" main-action="CREATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
<override name="fromDate" optional="true"/>
@@ -1608,6 +1609,7 @@ under the License.
<service name="createProductGroupOrder" default-entity-name="ProductGroupOrder" engine="groovy"
location="component://product/src/main/groovy/org/apache/ofbiz/product/product/product/ProductServicesScript.groovy" invoke="createProductGroupOrder" auth="true">
<description>Create ProductGroupOrder</description>
+ <permission-service service-name="productGenericPermission" main-action="CREATE"/>
<auto-attributes include="pk" mode="OUT" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
</service>
diff --git a/applications/product/servicedef/services_cost.xml b/applications/product/servicedef/services_cost.xml
index 02859c582f..dd88461f55 100644
--- a/applications/product/servicedef/services_cost.xml
+++ b/applications/product/servicedef/services_cost.xml
@@ -26,17 +26,20 @@ under the License.
<service name="createCostComponent" default-entity-name="CostComponent" engine="entity-auto" invoke="create" auth="true">
<description>Create a CostComponent</description>
+ <permission-service service-name="productGenericPermission" main-action="CREATE"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
<auto-attributes include="pk" mode="OUT" optional="false"/>
<!--<override name="costComponentTypeId" optional="false"/>-->
</service>
<service name="updateCostComponent" default-entity-name="CostComponent" engine="entity-auto" invoke="update" auth="true">
<description>Update a CostComponent</description>
+ <permission-service service-name="productGenericPermission" main-action="UPDATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
</service>
<service name="deleteCostComponent" default-entity-name="CostComponent" engine="entity-auto" invoke="delete" auth="true">
<description>Delete a CostComponent</description>
+ <permission-service service-name="productGenericPermission" main-action="DELETE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
</service>
<service name="recreateCostComponent" default-entity-name="CostComponent" engine="groovy"
@@ -55,16 +58,19 @@ under the License.
</service>
<service name="createProductCostComponentCalc" default-entity-name="ProductCostComponentCalc" engine="entity-auto" invoke="create" auth="true">
<description>Create a ProductCostComponentCalc</description>
+ <permission-service service-name="productGenericPermission" main-action="CREATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
</service>
<service name="updateProductCostComponentCalc" default-entity-name="ProductCostComponentCalc" engine="entity-auto" invoke="update" auth="true">
<description>Update a ProductCostComponentCalc</description>
+ <permission-service service-name="productGenericPermission" main-action="UPDATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
</service>
<service name="deleteProductCostComponentCalc" default-entity-name="ProductCostComponentCalc" engine="entity-auto" invoke="delete" auth="true">
<description>Delete a Example</description>
+ <permission-service service-name="productGenericPermission" main-action="DELETE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
</service>
<service name="getProductCost" engine="groovy" auth="true"
diff --git a/applications/product/servicedef/services_facility.xml b/applications/product/servicedef/services_facility.xml
index 05ffbc0ef9..4f6cd6a6f3 100644
--- a/applications/product/servicedef/services_facility.xml
+++ b/applications/product/servicedef/services_facility.xml
@@ -34,6 +34,11 @@ under the License.
<description>ProductFacility Permission Checking Logic</description>
<implements service="permissionInterface"/>
</service>
+ <service name="orderInventoryPermissionCheck" engine="groovy"
+ location="component://product/src/main/groovy/org/apache/ofbiz/product/product/inventory/InventoryServicesScript.groovy" invoke="orderInventoryPermissionCheck">
+ <description>Permission logic for order-related inventory reservation services</description>
+ <implements service="permissionInterface"/>
+ </service>
<!-- Product Inventory Services -->
<service name="createInventoryItem" default-entity-name="InventoryItem" engine="groovy"
location="component://product/src/main/groovy/org/apache/ofbiz/product/product/inventory/InventoryServicesScript.groovy" invoke="createInventoryItem" auth="true">
@@ -397,6 +402,7 @@ under the License.
<service name="balanceInventoryItems" engine="simple" transaction-timeout="600"
location="component://product/minilang/product/inventory/InventoryServices.xml" invoke="balanceInventoryItems" auth="true">
<description>Balance inventory items based on the new item specified which will have available inventory that back-order (negative ATP) reservations can be reassigned to.</description>
+ <permission-service service-name="orderInventoryPermissionCheck" main-action="UPDATE"/>
<attribute name="inventoryItemId" type="String" mode="IN" optional="false">
<type-validate>
<fail-property resource="ProductErrorUiLabels" property="facility.inventoryItemId"/>
@@ -1305,6 +1311,7 @@ under the License.
<service name="setOrderReservationPriority" engine="simple" invoke="setOrderReservationPriority"
location="component://product/minilang/product/inventory/InventoryServices.xml" auth="true">
<description>set order priority</description>
+ <permission-service service-name="orderInventoryPermissionCheck" main-action="UPDATE"/>
<attribute name="priority" mode="IN" type="String" optional="true"/>
<attribute name="orderId" mode="IN" type="String" optional="false"/>
</service>
diff --git a/applications/product/servicedef/services_pricepromo.xml b/applications/product/servicedef/services_pricepromo.xml
index 83f0ec0b9b..a00ad8307c 100644
--- a/applications/product/servicedef/services_pricepromo.xml
+++ b/applications/product/servicedef/services_pricepromo.xml
@@ -113,17 +113,20 @@ under the License.
<service name="createProductPriceAction" default-entity-name="ProductPriceAction" engine="entity-auto" invoke="create" auth="true">
<description>Create a ProductPriceAction</description>
+ <permission-service service-name="productPriceGenericPermission" main-action="CREATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
<override name="productPriceActionSeqId" mode="OUT"/>
</service>
<service name="updateProductPriceAction" default-entity-name="ProductPriceAction" engine="entity-auto" invoke="update" auth="true">
<description>Update a ProductPriceAction</description>
+ <permission-service service-name="productPriceGenericPermission" main-action="UPDATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
</service>
<service name="deleteProductPriceAction" default-entity-name="ProductPriceAction" engine="entity-auto" invoke="delete" auth="true">
<description>Delete a ProductPriceAction</description>
+ <permission-service service-name="productPriceGenericPermission" main-action="DELETE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
</service>
diff --git a/applications/product/servicedef/services_shipment.xml b/applications/product/servicedef/services_shipment.xml
index de4214a3f5..39015d9e8f 100644
--- a/applications/product/servicedef/services_shipment.xml
+++ b/applications/product/servicedef/services_shipment.xml
@@ -27,11 +27,13 @@ under the License.
<!-- Shipment Services -->
<service name="createCarrierShipmentMethod" engine="entity-auto" default-entity-name="CarrierShipmentMethod" invoke="create" auth="true">
<description>Creates A CarrierShipmentMethod</description>
+ <permission-service service-name="productGenericPermission" main-action="CREATE"/>
<auto-attributes entity-name="CarrierShipmentMethod" include="pk" mode="IN" optional="false"/>
<auto-attributes entity-name="CarrierShipmentMethod" include="nonpk" mode="IN" optional="true"/>
</service>
<service name="updateCarrierShipmentMethod" engine="entity-auto" default-entity-name="CarrierShipmentMethod" invoke="update" auth="true">
<description>Updates A CarrierShipmentMethod</description>
+ <permission-service service-name="productGenericPermission" main-action="UPDATE"/>
<auto-attributes entity-name="CarrierShipmentMethod" include="pk" mode="IN" optional="false"/>
<auto-attributes entity-name="CarrierShipmentMethod" include="nonpk" mode="IN" optional="true"/>
</service>
@@ -46,6 +48,7 @@ under the License.
</service>
<service name="updateShipmentMethodType" engine="entity-auto" default-entity-name="ShipmentMethodType" invoke="update" auth="true">
<description>Updates A ShipmentMethodType</description>
+ <permission-service service-name="productGenericPermission" main-action="UPDATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
</service>
@@ -964,6 +967,7 @@ under the License.
<service name="removeShipmentEstimate" engine="java"
location="org.apache.ofbiz.shipment.shipment.ShipmentServices" invoke="removeShipmentEstimate" auth="true">
<description>Remove Shipment Estimate</description>
+ <permission-service service-name="productGenericPermission" main-action="DELETE"/>
<attribute name="shipmentCostEstimateId" type="String" mode="IN" optional="false"/>
</service>
@@ -1254,6 +1258,7 @@ under the License.
</service>
<service name="updateShipmentTimeEstimate" engine="entity-auto" invoke="update" default-entity-name="ShipmentTimeEstimate" auth="true">
<description>Update a ShipmentTimeEstimate</description>
+ <permission-service service-name="productGenericPermission" main-action="UPDATE"/>
<auto-attributes include="pk" mode="IN"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
</service>
@@ -1263,6 +1268,7 @@ under the License.
</service>
<service name="expireShipmentTimeEstimate" engine="entity-auto" invoke="expire" default-entity-name="ShipmentTimeEstimate" auth="true">
<description>Expire a ShipmentTimeEstimate</description>
+ <permission-service service-name="productGenericPermission" main-action="UPDATE"/>
<auto-attributes include="pk" mode="IN"/>
</service>
diff --git a/applications/product/servicedef/services_store.xml b/applications/product/servicedef/services_store.xml
index a605b73715..329184255b 100644
--- a/applications/product/servicedef/services_store.xml
+++ b/applications/product/servicedef/services_store.xml
@@ -376,11 +376,13 @@ under the License.
<!--ProductStoreGroup Services -->
<service name="createProductStoreGroup" default-entity-name="ProductStoreGroup" engine="entity-auto" invoke="create" auth="true">
<description>Create a ProductStoreGroup</description>
+ <permission-service service-name="productStoreGenericPermission" main-action="CREATE"/>
<auto-attributes include="pk" mode="OUT" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
</service>
<service name="updateProductStoreGroup" default-entity-name="ProductStoreGroup" engine="entity-auto" invoke="update" auth="true">
<description>Update a ProductStoreGroup</description>
+ <permission-service service-name="productStoreGenericPermission" main-action="UPDATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
</service>
@@ -390,6 +392,7 @@ under the License.
</service>
<service name="createProductStoreGroupMember" default-entity-name="ProductStoreGroupMember" engine="entity-auto" invoke="create" auth="true">
<description>Create a ProductStoreGroupMember</description>
+ <permission-service service-name="productStoreGenericPermission" main-action="CREATE"/>
<auto-attributes include="pk" mode="IN" optional="false"/>
<auto-attributes include="nonpk" mode="IN" optional="true"/>
</service>
diff --git a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/inventory/InventoryServicesScript.groovy b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/inventory/InventoryServicesScript.groovy
index 2c9a345179..ebe12f0de9 100644
--- a/applications/product/src/main/groovy/org/apache/ofbiz/product/product/inventory/InventoryServicesScript.groovy
+++ b/applications/product/src/main/groovy/org/apache/ofbiz/product/product/inventory/InventoryServicesScript.groovy
@@ -68,6 +68,22 @@ Map facilityGenericPermission() {
return result
}
+/**
+ * Permission logic for order-related inventory reservation services (balanceInventoryItems,
+ * setOrderReservationPriority), which are reached through the order manager rather than the catalog.
+ * @return Map with hasPermission boolean and potential failure message.
+ */
+Map orderInventoryPermissionCheck() {
+ String mainAction = parameters.mainAction
+ require(mainAction as boolean, 'ProductUiLabels', 'ProductMissingMainActionInPermissionService')
+ Map result = success()
+ result.hasPermission = security.hasEntityPermission('ORDERMGR', "_${mainAction}", parameters.userLogin)
+ if (!result.hasPermission) {
+ result = failure('ProductUiLabels', 'ProductPermissionError')
+ }
+ return result
+}
+
/**
* ProductFacility Permission Checking Logic
* @return Map with hasPermission boolean and potential failure message.