0


missing authentication credentials for REST request

ES curl请求报错:

curl -X GET "localhost:9200/megacorp/employee/_search?q=last_name:Smith&pretty"
{
  "error" : {
    "root_cause" : [
      {
        "type" : "security_exception",
        "reason" : "missing authentication credentials for REST request [/megacorp/employee/_search?q=last_name:Smith&pretty]",
        "header" : {
          "WWW-Authenticate" : "Basic realm=\"security\" charset=\"UTF-8\""
        }
      }
    ],
    "type" : "security_exception",
    "reason" : "missing authentication credentials for REST request [/megacorp/employee/_search?q=last_name:Smith&pretty]",
    "header" : {
      "WWW-Authenticate" : "Basic realm=\"security\" charset=\"UTF-8\""
    }
  },
  "status" : 401
}

原因: ES配置了密码认证,curl发起请求的时候需要带上认证信息

curl --user elastic:password -X GET "localhost:9200/megacorp/employee/_search?q=last_name:Smith&pretty"    
{
  "took" : 4,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 0.35667494,
    "hits" : [
      {
        "_index" : "megacorp",
        "_type" : "employee",
        "_id" : "2",
        "_score" : 0.35667494,
        "_source" : {
          "first_name" : "Jane",
          "last_name" : "Smith",
          "age" : 32,
          "about" : "I like to collect rock albums",
          "interests" : [
            "music"
          ]
        }
      },
      {
        "_index" : "megacorp",
        "_type" : "employee",
        "_id" : "1",
        "_score" : 0.35667494,
        "_source" : {
          "first_name" : "John",
          "last_name" : "Smith",
          "age" : 27,
          "about" : "I love to go rock climbing",
          "interests" : [
            "sports",
            "music"
          ]
        }
      }
    ]
  }
}
标签: 安全 http https

本文转载自: https://blog.csdn.net/JSWANGCHANG/article/details/121350460
版权归原作者 老王笔记 所有, 如有侵权,请联系我们删除。

“missing authentication credentials for REST request”的评论:

还没有评论