From d54af5ff2167bee3eb68d02e210283314ef74712 Mon Sep 17 00:00:00 2001 From: Robin Cawser Date: Mon, 7 Feb 2022 08:44:32 +0000 Subject: [PATCH] Filter params from PUT requests in security plugin when not all are required Signed-off-by: Robin Cawser --- src/OpenSearch/Namespaces/SecurityNamespace.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/OpenSearch/Namespaces/SecurityNamespace.php b/src/OpenSearch/Namespaces/SecurityNamespace.php index 5cbd88573..d2aacb0d1 100644 --- a/src/OpenSearch/Namespaces/SecurityNamespace.php +++ b/src/OpenSearch/Namespaces/SecurityNamespace.php @@ -70,11 +70,11 @@ public function createRole(array $params = []) { $endpointBuilder = $this->endpoints; $endpoint = $endpointBuilder('Security\CreateRole'); - $endpoint->setBody([ + $endpoint->setBody(array_filter([ 'cluster_permissions' => $this->extractArgument($params, 'cluster_permissions'), 'index_permissions' => $this->extractArgument($params, 'index_permissions'), 'tenant_permissions' => $this->extractArgument($params, 'tenant_permissions'), - ]); + ])); $endpoint->setRole($this->extractArgument($params, 'role')); $endpoint->setParams($params); @@ -94,11 +94,11 @@ public function createRoleMapping(array $params = []) { $endpointBuilder = $this->endpoints; $endpoint = $endpointBuilder('Security\CreateRoleMapping'); - $endpoint->setBody([ + $endpoint->setBody(array_filter([ 'backend_roles' => $this->extractArgument($params, 'backend_roles'), 'hosts' => $this->extractArgument($params, 'hosts'), 'users' => $this->extractArgument($params, 'users'), - ]); + ])); $endpoint->setRole($this->extractArgument($params, 'role')); $endpoint->setParams($params); @@ -139,12 +139,12 @@ public function createUser(array $params = []) { $endpointBuilder = $this->endpoints; $endpoint = $endpointBuilder('Security\CreateUser'); - $endpoint->setBody([ + $endpoint->setBody(array_filter([ 'password' => $this->extractArgument($params, 'password'), 'opendistro_security_roles' => $this->extractArgument($params, 'opendistro_security_roles'), 'backend_roles' => $this->extractArgument($params, 'backend_roles'), 'attributes' => $this->extractArgument($params, 'attributes'), - ]); + ])); $endpoint->setUsername($this->extractArgument($params, 'username')); $endpoint->setParams($params);