Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Elasticsearch basic HTTP authentication #372

Closed
wants to merge 7 commits into from

Conversation

mars
Copy link
Member

@mars mars commented Apr 20, 2017

Add optional username-password configuration for the new Elasticsearch 5 client; in pio-env.sh config:

# Optional basic HTTP auth
PIO_STORAGE_SOURCES_ELASTICSEARCH_USERNAME=my-name
PIO_STORAGE_SOURCES_ELASTICSEARCH_PASSWORD=my-secret

These credentials are sent in each Elasticsearch request as an HTTP Basic Authorization header.

Enables use of public-cloud, hosted Elasticsearch clusters, such as Bonsai on Heroku.

I'm looking into adding test coverage. (I have the Docker test suite setup now.)

case (Some(username), Some(password)) => Some(username, password)
case (Some(username), None) => Some(username, "")
case (None, Some(password)) => Some("", password)
case (None, None) => None}
Copy link
Member

Choose a reason for hiding this comment

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

This pattern match can be simpler like:

usernamePassword match {
  case (None, None)         => None
  case (username, password) => Some((username.getOrElse(""), password.getOrElse("")))
}

and Some(username, password) causes auto tuppling. It's warned by Scala compiler to avoid unintended conversion to arguments to tuple.

Copy link
Member Author

@mars mars Apr 21, 2017

Choose a reason for hiding this comment

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

Thanks for the feedback, @takezoe. Pushing this improvement now.

@mars mars force-pushed the esclient-auth branch 2 times, most recently from aa01be5 to 052f5d8 Compare May 23, 2017 22:22
@mars
Copy link
Member Author

mars commented Aug 14, 2017

Closing in favor of #421

@mars mars closed this Aug 14, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants