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

**URL:** <https://discuss.elastic.co/t/how-to-detect-route-changes-in-kibana-7-8-oss-version-using-history-listen/247700>\
**Category:** Kibana\
**Created:** [September 7, 2020, 5:05am UTC](https://discuss.elastic.co/t/how-to-detect-route-changes-in-kibana-7-8-oss-version-using-history-listen/247700 "2020-09-07T05:05:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jayanth\_Mogadampalli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jayanth_mogadampalli/32/74602_2.png) [@Jayanth\_Mogadampalli](https://discuss.elastic.co/u/Jayanth_Mogadampalli)\
**Post date:** [September 7, 2020, 5:05am UTC](https://discuss.elastic.co/t/how-to-detect-route-changes-in-kibana-7-8-oss-version-using-history-listen/247700/1 "2020-09-07T05:05:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![afharo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/afharo/32/75202_2.png) [@afharo](https://discuss.elastic.co/u/afharo)\
**Post date:** [September 14, 2020, 1:20pm UTC](https://discuss.elastic.co/t/how-to-detect-route-changes-in-kibana-7-8-oss-version-using-history-listen/247700/2 "2020-09-14T13:20:35Z")

</div>

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:

```auto
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](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](https://github.com/elastic/kibana/blob/master/docs/development/core/server/kibana-plugin-core-server.httpservicesetup.md))

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 12, 2020, 1:20pm UTC](https://discuss.elastic.co/t/how-to-detect-route-changes-in-kibana-7-8-oss-version-using-history-listen/247700/3 "2020-10-12T13:20:44Z")

</div>

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