http.asciidoc 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. [[http-clients]]
  2. === HTTP/REST clients and security
  3. The {es} {security-features} work with standard HTTP
  4. {wikipedia}/Basic_access_authentication[basic authentication]
  5. headers to authenticate users. Since Elasticsearch is stateless, this header must
  6. be sent with every request:
  7. [source,shell]
  8. --------------------------------------------------
  9. Authorization: Basic <TOKEN> <1>
  10. --------------------------------------------------
  11. <1> The `<TOKEN>` is computed as `base64(USERNAME:PASSWORD)`
  12. [float]
  13. ==== Client examples
  14. This example uses `curl` without basic auth to create an index:
  15. [source,shell]
  16. -------------------------------------------------------------------------------
  17. curl -XPUT 'localhost:9200/idx'
  18. -------------------------------------------------------------------------------
  19. [source,js]
  20. -------------------------------------------------------------------------------
  21. {
  22. "error": "AuthenticationException[Missing authentication token]",
  23. "status": 401
  24. }
  25. -------------------------------------------------------------------------------
  26. Since no user is associated with the request above, an authentication error is
  27. returned. Now we'll use `curl` with basic auth to create an index as the
  28. `rdeniro` user:
  29. [source,shell]
  30. ---------------------------------------------------------
  31. curl --user rdeniro:taxidriver -XPUT 'localhost:9200/idx'
  32. ---------------------------------------------------------
  33. [source,js]
  34. ---------------------------------------------------------
  35. {
  36. "acknowledged": true
  37. }
  38. ---------------------------------------------------------
  39. [float]
  40. ==== Client Libraries over HTTP
  41. For more information about using {security-features} with the language
  42. specific clients, refer to
  43. https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-transport#authentication[Ruby],
  44. http://elasticsearch-py.readthedocs.org/en/master/#ssl-and-authentication[Python],
  45. https://metacpan.org/pod/Search::Elasticsearch::Cxn::HTTPTiny#CONFIGURATION[Perl],
  46. http://www.elastic.co/guide/en/elasticsearch/client/php-api/current/_security.html[PHP],
  47. http://nest.azurewebsites.net/elasticsearch-net/security.html[.NET],
  48. http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html[JavaScript]
  49. ////
  50. Groovy - TODO link
  51. ////