Hiding password values


#1

In my plot dashboard project, I am using plotly simple auth,

this is standard in plolty simple HTTP auth,

Issue 1, I need to hide my password pairs,

in the ploty docs, we see this configuration,

Keep this out of source code repository - save in a file or a database VALID_USERNAME_PASSWORD_PAIRS = [ [‘hello’, ‘world’] ] app = dash.Dash(‘auth’) auth = dash_auth.BasicAuth( app, VALID_USERNAME_PASSWORD_PAIRS )

here is my repo, https://github.com/90t/my_dash_app

Basically, I need to hide my password,

my app is on Heroku ,

Can someone plaese help me with this ??,
Thank you


#2

Try setting environment variables on heroku and then referencing them in your code using os.environ['MY_USERNAME'] where MY_USERNAME is a variable you set on Heroku.


#3

Thanks, but do I need to make a env file or a config file ? to reference the username & password & then inject through the herokucli,

Thanks


#4

Once you add the environment variables to your heroku container I think you can reference them using os.environ in your code directly where you need your password/username.


#5

If I createplotly2 plotly1 plotly a .env file declare my USERNAME_PASSWORD_PAIRS=(not sure of the correct syntax for this file !!),

install python-dotenv import my config file into my app,

But I am missing a great deal here I think


#6

If the list of user/password is big and static, I would put it on a private cdn (eg: AWS S3) and load it from there.

For a dynamic list you would need a database.


#7

No its just a password & username,

Should I not be creating a env file a config file, then declare the values in the .env file gitgnore the .env file,

Reference the values in the config file

config.py

import os
basedir = os.path.abspath(os.path.dirname(file))

USERNAME_PASSWORD_PAIRS =[
[‘USERNAME’, ‘PASSWORD’]
]

.env
USERNAME_PASSWORD_PAIRS;[
[‘ploty’,‘dash’]
]

app.py

here is my repo it is 1 commit behind, I haven’t pushed any of this config code yet


#8

I think now I need to just fix my app file

plotly3