Black Lives Matter. Please consider donating to Black Girls Code today.

Dash Auth with multi-page app - request authentication in sub URL instead of 403 error

Hi,

I have a multi-page app following the instructions here.

To simplify a little bit, the app structure is something like this:

- app.py
- index.py
- apps
   |-- __init__.py
   |-- app1.py
   |-- app2.py

I’m able to set Dash Auth to work so that if the user goes to the “landing page” (when debugging, localhost:8050) it prompts the user to log in using the Plotly account. However, if the user goes to, for example, localhost:8050/apps/app1, they get a 403 error (Forbidden).

The behavior I would like to have is one of the following:

  • The user goes directly to localhost:8050/apps/app1 and instead of the 403 error he/she gets prompted to authenticate and then is redirected to the page that was initially requested.

Or if this is not possible:

  • The app is redirected to localhost:8050 if the user tries to access a sub page and they aren’t authenticated yet.

I tried the second approach using the @auth.is_authorized_hook decorator but haven’t had much success yet. Does anyone know if what I’m trying to do is possible?

Thanks!

Multi-apps is not supported by dash-auth currently, sorry.

1 Like

Hi Philippe. Is Multi-apps now supported by dash-auth? if not, what is the recommended way to secure the App?

2 Likes

Hi. Just to follow up on this, is support to multi-page apps going to be added in the next releases? Thanks!