How to detect route changes in kibana 7.8 OSS version using history.listen()

I am developing a plugin for authentication and authorization
For authorization, I need to protect all the routes
So, I tried to listen to route changes using history.listen() in app_router.tsx file present in repo
But it is not working. It is not detecting routeChange event in kibana.(for eg: '/app/kibana' is not being detected)
Please provide piece of code or in which component this code need to be written in kibana

Hi @Jayanth_Mogadampalli

I think you are after the core.http.registerAuth() method. In your server/plugin.ts file, your setup method can look something like:

public setup({ http }: CoreSetup) {
  http.registerAuth((request, response, toolkit) => {
    // Perform auth checks
  })
}

Docs can be found in https://github.com/elastic/kibana/blob/master/docs/development/core/server/kibana-plugin-core-server.httpservicesetup.registerauth.md

Alternatively, you might also want to take a look at registerOnPostAuth and registerOnPreAuth (https://github.com/elastic/kibana/blob/master/docs/development/core/server/kibana-plugin-core-server.httpservicesetup.md)

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