Skip to content

Support Elasticsearch basic authentication #85

@sarab2009

Description

@sarab2009

The Client.php construction doesn't handle the BasicAuthentication for Elasticsearch and ignores ES_USER and ES_PASSWORD environment variables.

Expected behavior
The construction function should be something like this:
` public function __construct(array $hosts, string $username, string $password, LoggerInterface $logger)
{
if (!empty($username) && !empty($password)) {
$this->client = ClientBuilder::create()
->setHosts($hosts)
->setBasicAuthentication($username, $password)
->build();
} else {
$this->client = ClientBuilder::create()
->setHosts($hosts)
->build();
}

    $this->logger = $logger;

    $namespace = getenv('ES_NAMESPACE');

    $this->namespace = $namespace ? $namespace . '_' : '';
}`

Screenshots
image

Environment (please complete the following information):

  • OS name and version: Ubuntu 20.04.5 LTS x64
  • PHP version: PHP 8.1.12
  • Elasticsearch version: OpenSearch 2.3
  • AdServer version: AdServer v2.1.1
  • AdSelect version: AdSelect v1.2.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions