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

Indexing with basic auth #39

Open
andreas-andersson opened this issue Apr 10, 2024 · 1 comment
Open

Indexing with basic auth #39

andreas-andersson opened this issue Apr 10, 2024 · 1 comment

Comments

@andreas-andersson
Copy link

andreas-andersson commented Apr 10, 2024

Problem:
It's common practice to keep a staging or test server for a project and those are sometimes protected by Basic Auth.
Currently there is no way to index sites which has basic auth because there is no way of passing settings to the \GuzzleHttp\Client in ElementIndexerService ->getElementIndexableContent()

I have not found a way to work around this. Is there another way?


Suggestion:
Add a config option for the \GuzzleHttp\Client

config.php || ./config/elasticsearch.php

return [
    'httpClientOptions' => [
        'connection_timeout' => 10,
        'auth' => ['username', 'password']
    ]
]

/src/services/ElementIndexerService.php

protected function getElementIndexableContent(Element $element)
    {
        // ...
        $options = ElasticsearchPlugin::getInstance()->getSettings()->httpClientOptions;
        $client = new \GuzzleHttp\Client($options);
        // ...

/src/models/SettingsModel.php

class SettingsModel extends Model
{
    // ...
    /** @var array GuzzleHttp\Client options */
    public $httpClientOptions = [];
    // ...
@andreas-andersson
Copy link
Author

Let me know if this sounds interesting and I'll submit a PR for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant