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

Adds a AwsSigningHttpClientFactory #314

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kimpepper
Copy link
Collaborator

@kimpepper kimpepper commented Feb 27, 2025

Description

Adds a AwsSigningHttpClientFactory to simplify the creation of a signing HTTP client using the \OpenSearch\Aws\SigningClientDecorator.

Also updates auth guide.

Example usage:

$endpoint = 'https://search-example.us-west-2.es.amazonaws.com';

$symfonyClient = (new \OpenSearch\HttpClient\SymfonyHttpClientFactory()->create([
    'base_uri' => $endpoint, // required.
]);

Use the AwsSigningHttpClientFactory to create a signing HTTP client:

$signingHttpClient = (new \OpenSearch\Aws\AwsSigningHttpClientFactory($symfonyClient))->create([
    'access_key' => '...', // optional. Will fallback to AWS SDK credential discovery.
    'secret_key' => '...', // optional. Will fallback to AWS SDK credential discovery.
    'base_uri' => $endpoint, // required for signing.
    'region' => 'us-west-2', // required for signing.
    'session_token' => '...', // optional.
    'service' => 'es', // optional. Allowed values are: 'es', 'aoss'. Defaults to 'es'.
  ],
]);

Issues Resolved

#257

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@dblock
Copy link
Member

dblock commented Feb 27, 2025

This looks like a very odd interface subclassing a client. In other clients Sigv4 is just a kind of auth that signs requests (adds headers), similar to basic auth. I think it should be something like this:

$endpoint = 'https://search-example.us-west-2.es.amazonaws.com';

$symfonyClient = (new \OpenSearch\HttpClient\SymfonyHttpClientFactory()->create([
    'base_uri' => $endpoint,
    'auth' => new \OpenSearch\Aws\AwsAuth(key, token, ...)
]);

AwsAuth would be something callable.

WDYT?

@kimpepper
Copy link
Collaborator Author

That would be specific to Symfony client. We'd need to do the same for Guzzle.

This is a decorator around any PSR Client.

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

Successfully merging this pull request may close these issues.

2 participants