Calling custom plugins from Kibana

Hi,

How can I call the rest end points exposed by my custom plugin using Kibana? The end points are authenticated.

What do you mean by "calling" them? What do you want to do with the endpoints?

For example assume that my plugin has an api: /my-plugin/users , I can access the same endpoint from browser using the url: http://localhost:9200/my-plugin/users.

My requirement is to call this endpoint from the Kibana plugin that I'm building and display the response on the screen. Since the endpoint uses Cookie for authentication, I need to be able to pass the cookie from Kibana to the endpoint.

Do you want to display the response on the screen in your own app, or in some other app (like, the ones bundled with the Kibana UI; Discovery, Dashboard, Visualize, etc)? Both are possible, and even making that happen in another external plugin is possible, but the way you'd do that is different.

If it's your own app, you can just build your own UI and do it however you want. Trigger it on load, on some button press, whatever you can dream up. If you want to make it happen from within Kibana, you're a little more limited because you can only use the hooks that exist there. The most likely candidate is probably the navbar extensions, which allows you to inject a button in the top nav of an application.

Since the endpoint uses Cookie for authentication, I need to be able to pass the cookie from Kibana to the endpoint.

This makes it a bit trickier if you're rolling your own authentication. You need a way to create the cookie in the first place, on the same protocol, hostname, and port that Kibana runs on. So you effectively need a way to create that cookie from Kibana. This isn't impossible, but it will require you to add your own login routine in your plugin. You can intercept the request and force users to log in that way, and also check for an existing cookie and make sure it's valid before passing allowing the request to continue. Once you have that, the browser will take care of the rest.

If you're using X-Pack Security, it comes will all that set up already, you simply need to use the Security plugin in your plugin to get authentication details (assuming you need them; if your plugin loads at that point, the user is authenticated).

Hopefully that's helpful. If you can describe in more details what your authentication needs are here, I can help point you in the right direction.

Is it possible to write custom APIs by extending elasticsearch.js. Followed this link : https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/extending_core_components.html but keep getting invalid end point for my apis

It's possible, yes. We use that to write interfaces to plugins in Elasticsearch. If you're not writing custom functionality into Elasticsearch, via a plugin there, but instead you're extending Kibana with APIs via a plugin in Kibana, I'm not sure that it's what you actually want.

I don't know that system really at all. Maybe @spalger can chime in here.

The issue got resolved. I used "transport.request" api of elasticsearch-js to get response from custom end points.

Can you guide me to some examples on login routines?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.