elastically icon indicating copy to clipboard operation
elastically copied to clipboard

How to configure Basic Auth with Symfony

Open xvilo opened this issue 1 year ago • 1 comments

Hi,

I couldn't find it in the documentation, but what would be the prefered way to configure basic auth for the elastic search endpoint when using the Symfony configuration?

Currently I'm using the provided example mainly:

elastically:
  connections:
    # You can create multiple clients
    default:
      # Any Elastica option works here
      client:
        hosts:
          - 'es.example.com'

      # Path to the mapping directory (in YAML)
      mapping_directory: '%kernel.project_dir%/config/elasticsearch'

      # Size of the bulk sent to Elasticsearch (default to 100)
      bulk_size: 100

      # If you want to add a prefix for your index in elasticsearch (you can still call it by its base name everywhere!)
      prefix: '%kernel.environment%'

      # Use HttpClient component
      transport_config:
        http_client: 'Psr\Http\Client\ClientInterface'

But I'm unsure as to where to configure the username and password

xvilo avatar Nov 25 '24 09:11 xvilo

Hello,

According to Elastica it's in the config, so put it inside "client".

https://github.com/ruflin/Elastica/blob/58042887616eeb63621412c03bc903056bbcee7e/src/Client.php#L599-L601

elastically:
  connections:
    # You can create multiple clients
    default:
      # Any Elastica option works here
      client:
        hosts:
          - 'es.example.com'
        username: xoxo
        password: secret

damienalexandre avatar Nov 25 '24 11:11 damienalexandre