原英文版地址: https://www.elastic.co/guide/en/elasticsearch/reference/7.7/http-clients.html, 原文档版权归 www.elastic.co 所有
本地英文版地址: ../en/http-clients.html
本地英文版地址: ../en/http-clients.html
重要: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 当前版本文档。
HTTP/REST clients and securityedit
The Elasticsearch security features work with standard HTTP basic authentication headers to authenticate users. Since Elasticsearch is stateless, this header must be sent with every request:
Client examplesedit
This example uses curl without basic auth to create an index:
curl -XPUT 'localhost:9200/idx'
{
"error": "AuthenticationException[Missing authentication token]",
"status": 401
}
Since no user is associated with the request above, an authentication error is
returned. Now we’ll use curl with basic auth to create an index as the
rdeniro user:
curl --user rdeniro:taxidriver -XPUT 'localhost:9200/idx'
{
"acknowledged": true
}
Client libraries over HTTPedit
For more information about using security features with the language specific clients, refer to: