Skip to content

Allow cloning the transport with different credentials #260

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

swallez
Copy link
Member

@swallez swallez commented Jun 30, 2025

Add Transport::clone_with_auth() that clones a transport (http client and connection pool) with a different authentication. The primary use case is for multi-tenant applications where multiple different credentials can be used to connect to the same Elasticsearch cluster.

To make it easier to set any kind of authentication header, this PR also adds a new kind of credentials, Credentials::AuthorizationHeader that accepts any string value.

@swallez swallez requested review from Anaethelion and Copilot June 30, 2025 16:54
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds a new method to clone the transport instance with different authentication credentials, enabling multi-tenant applications to efficiently switch credentials when connecting to the Elasticsearch cluster.

  • Introduces the clone_with_auth() method to create a copy of the transport with a new set of credentials.
  • Provides a test (clone_with_credentials) to verify that the new transport properly holds the new authentication data.
  • Updates the transport implementation to support cloning of relevant fields, including the HTTP client and connection pool.
Comments suppressed due to low confidence (1)

elasticsearch/src/http/transport.rs:1317

  • Consider renaming the test function 'clone_with_credentials' to 'clone_with_auth' for consistency with the API method name.
    fn clone_with_credentials() -> anyhow::Result<()> {

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.

1 participant