BasicAuth failing with Dash 2.6

Hi all I believe there is a bug when using BasicAuth with Dash 2.6 (it is working fine with 2.5.1).

The error I receive is the following, I have a hunch it’s got something to do with the fix to allow redirection from “/” in 2.6, @AnnMarieW ?

Traceback (most recent call last):
  File "/home/renaud/repos/enea/vetef-ui/vetef_ui/application.py", line 36, in <module>
    auth = dash_auth.BasicAuth(app, USER_AUTHENTICATION)
  File "/home/renaud/miniconda3/envs/dash/lib/python3.9/site-packages/dash_auth/basic_auth.py", line 8, in __init__
    Auth.__init__(self, app)
  File "/home/renaud/miniconda3/envs/dash/lib/python3.9/site-packages/dash_auth/auth.py", line 12, in __init__
    self._overwrite_index()
  File "/home/renaud/miniconda3/envs/dash/lib/python3.9/site-packages/dash_auth/auth.py", line 18, in _overwrite_index
    original_index = self.app.server.view_functions[self._index_view_name]
KeyError: '/'

Hi @RenaudLN

Are you using pages? The update I did should only affect when use_pages=True.

Yes I am :slight_smile:

Thanks for reporting @RenaudLN

@AnnMarieW, would you like me to open an issue or would you like some time to take a deeper look at this?

I’m having a similar, if not the same, issue with a custom rolled version of BasicAuth. When I switch the use_pages flag to False the app can then load the / route fine.

Hi @gabrielcenteno and welcome to the Dash community :slightly_smiling_face:

This bug is new in 2.6.0. Still working on the fix, but if you would like to use pages, then another option is to use dash==2.5.1

1 Like

Hi @AnnMarieW -

I believe that I’m experiencing the same error now. Do you happen to know if it was supposed to have been fixed?

Thanks,
Nick

Yes, try upgrading to the latest version of dash.
There are some other issues related to BasicAuth, but the one reported in this thread has been fixed

1 Like

Ah, thanks. My apologies - I just went with this example without realizing that it was on an older version of Dash. After upgrading things are working. Thanks for your help @AnnMarieW.

1 Like