Dash authentication for multiple password and users


I have a question: in Dash authentication instruction it says that I should store password/user in a file or a database outside of source code repository. How do I do it? Do I create .py file? What file to store it and then how to pass this file to my dash app?

Also, I want to use different data sources based on credentials (user1 gest Data1.csv and so on). Is it possible?

Thanks in advance for help.

Best regards


Havent done this myself yet, and im going for a much more complicated Authentication then the shown ones from Dash the next week, But you can probably safe the Usernames/Password any way you like. In a different .py, as JSON or as pure text. At the end you will just need to be able to process that data to your usernames:password pairs in your main dash .py. You will have to play around with this, but i think you could be able to add some sort of group key to every pair, which loads and is set with the authentication at the beginning. This could then be just used in if-cases to decide which .csv should be loaded. If things are unclear, I will probably give this a go next week myself, I´ll look into here again. Cheers!


Thanks for reply. Well, I am a beginner without programming backrgoud (I worked on Excel, SAS, SAP…) so many definitions don’t say anything to me.
However, I decided to start leraning Python/Dash. I am trying to replicate stuff that I did in Excel/Vba using Dash.

I would very much appreciate if you could get back to me next week and maybe help me a little bit more. In the meantime I will try to do it myself.

Tanks again.


This might be a bit hard for a beginner (you would need at least a bit of a high-level understanding of SQL, Flask, and SQLAlchemy) but there are very few files and if you read carefully you will manage. Take a look at: https://github.com/RafaelMiquelino/dash-flask-login

A bit more complex version of that is what I’m using for my app. It would be best if you didn’t store passwords but hashes, e.g.:

hashed = hash("my_password")
users_dict["awesome_user"] = hashed

If you don’t want to use SQL, CSV and JSON are both fine, but using hashes is the important part. Then, if you want to log a user in, you just do the same thing:

hashed = hash("my_password")
if hashes == users_dict["awesome_user"]:

Now, for addressing the “different users get different data” part, I’d just save them as lists in a dictionary (or similar) like the following:

user1 = "myself"
user2 = "you"
data1 = "data1.csv"
data2 = "data2.csv"
data3 = "data3.csv"
data_dict[user1] = [data1, ]  # only has access to dataset 1
data_dict[user2] = [data2, data3]  # super user, has access to 2 datasets 

or maybe you can directly save the data with composite keys:

data_dict[(user1, "data1.csv")] = pd.DataFrame([1,2,3])
data_dict[(user2, "data2.csv")] = pd.DataFrame([99,2,4])
data_dict[(user2, "data3.csv")] = pd.DataFrame([3,7,4])

If you only have a user, you can iterate over data_dict.keys().

Good luck :slight_smile:

Hełmy Man,

Thanks for reply. Would you mind if i contacted you on monday?
I have some problems with flask tunningu and maube you could help me?



so I have implemented OAuth into my Dash App. Take a look at the flask-pyoidc module for more info. You will need to setup your own oauth server tho. But it gives you a really cool login with a lot of cool features. And does all the authorization u need for you.

Thanks Man, thanks a lot.

Will give it a look. Right now I have some other projects and I m short on time but will try to look at it first thing next week.

Best regards

For anyone who struggles with this problem in the future, I’ve built out a template to support multiple users with dedicated views in Dash.

I hit many dead ends while trying to find a solution, so I hope this will help someone.

1 Like

Hi @seanmajorpayne, I installed your template and I’m using the DB Browser program to edit the app.db file. But I noticed that the default password “pw” is encrypted. If I want to add a user, would it work if I use a sha-256 online encrypter?


If I store the multiple users and password in SQL database, how can I link/call it in my dashboard when user login?