1

I want to have a user which has a read-only access to a given index. I have read the Elasticsearch documentation and learnt that this can be achieved using the xpack API provided by Elasticsearch as a security feature. Now I am using "IBM Cloud Databases for Elasticsearch" and it comes with Elasticsearch 6.8.4, I am successfully able to communicate with it via Python and REST APIs as well and can manage to create index document etc but I am not able to use any of the xpack methods at all, not even the basic ones like get_role or get_user, it gives an error that I have attached herewith. I have also tried a same Elasticsearch version locally deployed on my machine and I am successfully able to use all the xpack methods. Below are the examples of how I am trying to use get_user method using requests and elasticsearch python.

Here is the requests method used and the response:

# 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()

Response:

{'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}

Here is python elasticsearch same method and response:

# 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()

Response:

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]')

Additionally, in the second method, the error is different but if instead I use put_user, it throws the exact same 500 error the former method throws.

I am using the default user and service credentials that IBM Cloud creates for authentication.

Update: This is the link to the service that I am using (Contains Documentation link as well): https://cloud.ibm.com/catalog/services/databases-for-elasticsearch

1 Answers1

0

That's because IBM Cloud Databases for Elasticsearch doesn't use xpack. So, if you're attempting to use it, it won't work. Currently, they only have one type of user.

Dr G.
  • 1,298
  • 9
  • 17