授予对用户IBM Cloud Elasticsearch的只读访问权限

问题描述 投票:1回答:1

我想拥有一个对给定索引具有只读访问权限的用户。我已经阅读了Elasticsearch文档,并了解到可以使用Elasticsearch提供的xpack API作为安全功能来实现。现在,我正在使用“用于Elasticsearch的IBM云数据库”,它随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

elasticsearch ibm-cloud elasticsearch-x-pack
1个回答
0
投票

这是因为用于Elasticsearch的IBM Cloud Database不使用xpack。因此,如果您尝试使用它,它将无法使用。

© www.soinside.com 2019 - 2024. All rights reserved.