1

我希望有一个对给定索引具有只读访问权限的用户。我已阅读 Elasticsearch 文档并了解到这可以使用 Elasticsearch 提供的 xpack API 作为安全功能来实现。现在我正在使用“IBM Cloud Databases for Elasticsearch”,它随 Elasticsearch 6.8.4 一起提供,我也能够通过 Python 和 REST API 成功地与之通信,并且可以设法创建索引文档等,但我无法使用根本没有任何 xpack 方法,甚至不是像 get_role 或 get_user 这样的基本方法,它都会给出一个错误,我附在此处。我还尝试了在我的机器上本地部署的相同 Elasticsearch 版本,并且我能够成功使用所有 xpack 方法。下面是我如何尝试使用请求和 elasticsearch python 的 get_user 方法的示例。

这是使用的请求方法和响应:

# Get User via requests

endpoint = "https://9fb4-f729-4d0c-86b1-da.eb46187.databases.appdomain.cloud:31248/_xpack/security/user"

header = {'Authorization': access_token,
          'Content-Type': 'application/json',
          'Accept': 'application/json'}

requests.get(url=endpoint, 
              auth=(cred_elastic["username"],cred_elastic['password']), 
              verify='./cert.pem',
              headers=header).json()

回复:

{'error': {'root_cause': [{'type': 'security_exception',
    'reason': 'Unexpected exception indices:data/read/get'}],
  'type': 'security_exception',
  'reason': 'Unexpected exception indices:data/read/get'},
 'status': 500}

这是 python elasticsearch 相同的方法和响应:

# Creating Elasticsearch Object
context = create_default_context(cadata=cred_elastic['tls_certificate'])
es = Elasticsearch(cred_elastic['endpoint'],
                   ssl_context=context,
                   http_auth=(cred_elastic['username'],
                              cred_elastic['password']))
es.security.get_user()

回复:

TransportError: TransportError(405, 'Incorrect HTTP method for uri [/_security/user] and method [GET], allowed: [POST]', 'Incorrect HTTP method for uri [/_security/user] and method [GET], allowed: [POST]')

此外,在第二种方法中,错误是不同的,但如果我使用 put_user,它会抛出与前一种方法完全相同的 500 错误。

我正在使用 IBM Cloud 为认证创建的默认用户和服务凭证

更新:这是我正在使用的服务的链接(也包含文档链接): https ://cloud.ibm.com/catalog/services/databases-for-elasticsearch

4

1 回答 1

0

这是因为 IBM Cloud Databases for Elasticsearch 不使用 xpack。因此,如果您尝试使用它,它将无法正常工作。目前,他们只有一种类型的用户。

于 2020-06-11T06:17:37.377 回答