Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] ClientBuilder::fromConfig overrides basic authentication #159

Closed
CSalih opened this issue Jul 6, 2023 · 0 comments · Fixed by #160
Closed

[BUG] ClientBuilder::fromConfig overrides basic authentication #159

CSalih opened this issue Jul 6, 2023 · 0 comments · Fixed by #160
Labels
bug Something isn't working

Comments

@CSalih
Copy link
Contributor

CSalih commented Jul 6, 2023

What is the bug?

Creating the Client with ClientBuilder::fromConfig may overrides basic authentication depending on the order of the given $config array.

How can one reproduce the bug?

$client = [
    'basicAuthentication' => [...],
    'connectionParams' => [
        'client' => [
            'curl' => [...],
        ],
    ],
];

// The call ClientBuilder->setConnectionParams() will override basic authentication
$this->client = ClientBuilder::fromConfig($client);

fromConfig will call ClientBuilder->setConnectionParams() after ClientBuilder->setBasicAuthentication() and the basic authentication will be overridden, therefore the performed requests will result to status code 401.
The same behavior would also happen when someone calls $clientBuilder->setBasicAuthentication() before $clientBuilder->setConnectionParams().

What is the expected behavior?

The order of the $client properties should be in depended. ClientBuilder->setConnectionParams() needs to merge the given params with $this->connectionParams instead of overriding it.

What is your host/environment?


Do you have any screenshots?


Do you have any additional context?

opensearch-project/opensearch-php Version 2.2.0

I am ready to create a PR for this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants