Skip to content

Commit

Permalink
Filter params from PUT requests in security plugin when not all are r…
Browse files Browse the repository at this point in the history
…equired

Signed-off-by: Robin Cawser <[email protected]>
  • Loading branch information
Robin Cawser authored and shyim committed Feb 8, 2022
1 parent 7343d32 commit d54af5f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/OpenSearch/Namespaces/SecurityNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit d54af5f

Please sign in to comment.