How to hold Plotly dash app behind protected route How to hold Plotly dash app behind protected route flask flask

How to hold Plotly dash app behind protected route


I'll share a few resources I found researching the question:

  1. Dash provides a library named dash-auth, which you can install using pip install dash-auth
  2. Once you install the library, you'll be able to use import dash_auth, and you'll notice sub-modules for HTTP Basic Auth, OAuth, and "PlotlyAuth". "PlotlyAuth" has been deprecated, according to the text in from dash_auth.plotly_auth import deprecation_notice
  3. The source code for this module appears to be https://github.com/plotly/dash-auth
  4. Documentation is available at https://dash.plotly.com/authentication and a promotional page is available at https://plotly.com/dash/authentication/
  5. Presumably, JWT can be integrated using Flask's Response.set_cookie. Here are details about that approach, notice the author uses rep.set_cookie('custom-auth-session', username)
  6. There's an example on Github which uses Dash, Flask, and Flask-Login. This configuration also exists in a separate StackOverflow question. However, this library doesn't supports JWT. You may be able to achieve a similar architecture using the Flask-JWT-Extended library.