richlegrand / dash_devices

A fork of plotly/dash to help Dash deal with devices.
https://plotly.com/dash
MIT License
87 stars 11 forks source link

Application context #6

Open araldit opened 3 years ago

araldit commented 3 years ago

Hi, I would like to use quart_auth module for login/logout handling. To use this, I need access to the quart application context, but for some reason i cant. Do anyone have an example for getting the current application context, that I can use for storing user login information?

araldit commented 3 years ago

I have investigated this a little further. Because everything is websockets, there is no way to exhange cookies during a session - only during the initial handshake, but when the session is startet you can't. When a client has connected, this client will keep its connection open until the browser window closes. You can assign the client with a username and an authenticated flag as a kind of login mechanism and this will work as long as the current websocket connection is ongoing. Every time the client opens a new connection, he will need to be identified again, because there is no cookie control we can use. Another interesting find is, that dash_devices can't run a multipage site, where we control the pages with changing URL's. Instead we should make a single page site, where we change the layouts and widgets with callbacks only.

A way to implement true multi page sites with login can be done by using plain quart with a login screen and cookie handling. If the password or cookie is ok, we spawn the dash_devices site and set the user information in the websocket client session.

Is this rightly understood?