From 0442259154b1ac79daeb65799cfe91db3d3407f7 Mon Sep 17 00:00:00 2001 From: minimexat Date: Mon, 13 Jul 2026 14:29:21 +0200 Subject: [PATCH] FIX: restrict establishment setup API to admin users (#39137) * FIX: Restrict establishment setup API to admins * Update ChangeLog --------- Co-authored-by: f-hoedl Co-authored-by: Laurent Destailleur --- htdocs/api/class/api_setup.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 9e33ca357d3..ad0c3dd7b17 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -2744,6 +2744,9 @@ class Setup extends DolibarrApi public function getEstablishments() { $list = array(); + if (!DolibarrApiAccess::$user->admin) { + throw new RestException(403, 'Error API open to admin users only'); + } $limit = 0; @@ -2782,6 +2785,10 @@ class Setup extends DolibarrApi */ public function getEtablishmentByID($id) { + if (!DolibarrApiAccess::$user->admin) { + throw new RestException(403, 'Error API open to admin users only'); + } + $establishment = new Establishment($this->db); $result = $establishment->fetch($id); @@ -2790,6 +2797,9 @@ class Setup extends DolibarrApi } elseif ($result == 0) { throw new RestException(404, 'Establishment not found'); } + if (!in_array($establishment->entity, explode(',', getEntity('establishment')))) { + throw new RestException(404, 'Establishment not found'); + } return $this->_cleanObjectDatas($establishment); }