📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

版本: 8.9-8.9

简而言之,当向 Elasticsearch 发送 OPTIONS HTTP 请求时未提供适当的身份验证凭据,就会出现此错误。Elasticsearch 要求对所有类型的请求(包括 OPTIONS 请求)进行身份验证。要解决此问题,您可以在请求中提供有效的凭据,或者配置 Elasticsearch 允许未经身份验证的 OPTIONS 请求。此外,您还可以使用 API 密钥进行身份验证,或使用代理服务器在请求到达 Elasticsearch 之前处理 OPTIONS 请求。

日志上下文 #


日志"Cannot dispatch OPTIONS request; as they are not authenticated"的类名是 SecurityRestFilter.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考:

// 对于使用 OPTIONS 方法的 HTTP 请求,身份验证会被绕过;因此此健全性检查可防止调度未经身份验证的请求
 if (request.method() == Method.OPTIONS) {
 handleException(
 request;
 channel;
 new ElasticsearchSecurityException("Cannot dispatch OPTIONS request; as they are not authenticated")
 );
 return;
 }  if (enabled == false) {