Call elasticsearch API from custom Kibana plugin with relative url

I have created a custom kibana plugin, in that plugin i wanted to get infromation of user which has login with inbuilt API “GET _opendistro/_security/api/account”

I searched for API Reference | Elasticsearch JavaScript Client [8.4] | Elastic
In elastic they have below function call to do so.

client.security.authenticate()

what will be the opendistro version of this?

client.opendistro.security.api.account()

Can anybody has solution for how can I call above API from kibana custom plugin using server.route with relative url.

Hey @disha27! I’m moving this to the security category - you’ll get a better answer in that category.

@disha27
As you are using node.js client provided by elastic, this intentionally will not have support for opendistro.

Currently there are efforts to add new open source clients for connecting applications to any OpenSearch or Elasticsearch version 7 cluster, see further details here

But as of now, I don’t think there is anything else to offer the functionality you are looking for.

okay, my requirement is to disable custom plugin access for non-admin user. either by hiding it from left panel as like security plugin or disable text fields of all forms available inside plugin.
Is there any other way to check currently login user is admin or not and disable plugin access based on it?

@disha27
You should be able to call rest api _opendistro/_security/api/account from within your plugin using something like http.request , it might be awkward but should work.

I thought of using it this way as the last option. If there is no other way I may use axios to call this API.
but there is issue with this approach.
as elasticsearch API needs username/password, this API will print ouput for the user I have used to access API and not for the user logged in from kibana.

How security plugin is checking for the user is admin or not? Can I use the same part of code here in my plugin?