elastic / elasticsearch-rs

Official Elasticsearch Rust Client
https://www.elastic.co/guide/en/elasticsearch/client/rust-api/current/index.html
Apache License 2.0
705 stars 72 forks source link

[ENHANCEMENT] Implement Basic Authentication #15

Closed russcam closed 4 years ago

russcam commented 4 years ago

The client can currently connect to an Elasticsearch node at a single URI without any kind of authentication. The ability to provide Basic Authentication credentials to the client to use to connect to a URI should be implemented.

Possible implementation

ConnectionSettings is intended to be the struct that collects all relevant details needed to establish a connection to Elasticsearch, so the ability to pass Basic Authentication credentials logically sits as a field on ConnectionSettings.

Connection really depends on ConnectionSettings, so should arguably be passed as a ctor argument to create one, with Elasticsearch client now depending only on Connection. In future, there may be client specific settings unrelated to the Connection, but this dependency flow can be refactored if that need arises. Similarly, when #7 is implemented, Connection would be constructed by a ConnectionPool implementation, but again, this can be refactored when implementing connection pools.