Elasticquent icon indicating copy to clipboard operation
Elasticquent copied to clipboard

Failed to access when host url with username:password

Open yaofong opened this issue 8 years ago • 4 comments

I am using facetflow.io, a hosted elasticsearch. Their url have an API KEY prepend to the cluster url, such as:

https://apikey:@example.azure.facetflow.io

When I put in this URL to the config.hosts, facetflow returned error 401, authentication failed.

No problem when I was using aws elasticsearch, as they doesn't prepend any credential to the url.

So I wonder is this a problem with elasticquent or there are some problem with my server?

regards,

yaofong avatar Mar 07 '16 06:03 yaofong

What does your config/elasticquent.php look like?

This is my entire file for bonsai.io:

return array(

    /*
    |--------------------------------------------------------------------------
    | Custom Elasticsearch Client Configuration
    |--------------------------------------------------------------------------
    |
    | This array will be passed to the Elasticsearch client.
    | See configuration options here:
    |
    | http://www.elasticsearch.org/guide/en/elasticsearch/client/php-api/current/_configuration.html
    */

    'config' => [
        'hosts'     => ['https://[hidden]:[hidden]@book-index-[hidden].ap-southeast-2.bonsai.io'],
        'retries'   => 1,
    ],

    /*
    |--------------------------------------------------------------------------
    | Default Index Name
    |--------------------------------------------------------------------------
    |
    | This is the index name that Elasticquent will use for all
    | Elasticquent models.
    */

    'default_index' => 'book-index',

);

This configuration works fine for me.

timgws avatar Mar 07 '16 08:03 timgws

The configuration for Elasticquent w/ Facetflow is similar.

Go to your Security page inside Facetflow, and go to the access control page. Make sure if you are using a custom key (that is, anything but the unmodified default) that you click on the padlock, and ensure that there is enough access for that key to work:

screen shot 2016-03-07 at 4 20 31 pm

Make note of the key on the left hand side:

screen shot 2016-03-07 at 4 16 08 pm 2

That key will be used for your hosts config.

<?php
return array(
    'config' => [
        'hosts'     => [
            'https://1iHsUwgWkaE[hidden]:@elasticquent.east-us.azr.facetflow.io:443'
        ],
        'retries'   => 1,
    ],
);

Note that there is a colon (":") just before the at sign ("@").

You will realise that I have added the HTTPS port at the end of the host. This is to override the default inside Elasticsearch's library (which is 9200, when it is not set)

timgws avatar Mar 07 '16 08:03 timgws

@yaofong did this help?

timgws avatar Mar 10 '16 05:03 timgws

do some people have experience with AWS Elasticsearch calls w/ Elasticquent ?

unkndono avatar Aug 14 '18 15:08 unkndono