kittoframework / kitto

Kitto is a framework for interactive dashboards written in Elixir
http://kitto.io/dashboards/sample
MIT License
956 stars 58 forks source link

Loading another router #3

Open davejlong opened 7 years ago

davejlong commented 7 years ago

It would be really nice to have a way to add more routes to dashboard, for example to add authentication to the dashboard. Similar to how Dashing had the config.ru which you could add routes to.

zorbash commented 7 years ago

To be honest i'm not really fond of how dashing deals with authentication via config.ru.

Most dashing apps are deployed behind a reverse proxy like apache or nginx on which it's trivial to setup HTTP Basic Auth or IP range restrictions.

On the other hand I'm not negative on allowing the user to specify additional routes. An initial straightforward use case is hooks see: https://github.com/kittoframework/kitto/issues/4 where we allow a passive data flow for populating the widgets with data, as we let the user set triggers instead of polling a resource from a job.

davejlong commented 7 years ago

I have a couple use cases that I'm looking to accomplish. As you can see in cagedata/dashboard, we use Azure AD to authenticate to our dashboard app.

The other is for webhook support as you mentioned in #4.

For authentication, you could theoretically just take the opinionated route and pass to Ueberauth: if configured, force Ueberauth authentication, else the application is open.

davejlong commented 7 years ago

I'm thinking about implementing a forwarder in Kitto.Router. It would forward all requests to /my_dashboard, based on the application's name, to MyDashboard.Router which could implement it's own set of routes. This could also expand to include #4 as MyDashboard.Router would be able to handle any routes.

zorbash commented 7 years ago

I'd love to see a prototype of this.

davejlong commented 7 years ago

I'm back to working on a prototype for this. With targeting Heroku as a deployment option, I think it's necessary to be able to support authentication since Heroku doesn't offer anything else. I'm playing with Ueberauth to manage the auth logic.

davejlong commented 7 years ago

Circling back and thinking about it, I think the way to build this feature out is to allow a config option to specify a custom router. Then in the match _ block of Kitto.Router, check if the route exists and the other router and call it if it does.