Streamlit-Authenticator
Streamlit-Authenticator copied to clipboard
hashed password can be saved and loaded as file
This PR is related to issue https://github.com/mkhorasani/Streamlit-Authenticator/issues/9
This implements the possibility to automatically save the hashed_passwords as a file (with the .generate
method), and load it (with the .Authenticate
method).
The workflow looks like this:
names = ['John Smith', 'Rebecca Briggs']
usernames = ['jsmith', 'rbriggs']
passwords = ['123', '456']
hashed_passwords = stauth.Hasher(passwords).generate(folder_path="path_to_folder")
A .key file is then automatically generated at path_to_folder/hashed_passwords1546.key
1546
here is a random number generated when .Hasher.generate()
is called.
Then, when you need to use hashed_passwords
, you can use the legacy way with hashed_passwords
being a list:
authenticator = stauth.Authenticate(
names, usernames, hashed_passwords,
'some_cookie_name', 'some_signature_key', cookie_expiry_days=30,
)
Or you can alternatively use the saved hashed_passwords1546.key
file:
authenticator = stauth.Authenticate(
names, usernames,"path_to_folder/hashed_passwords1546.key",
'some_cookie_name', 'some_signature_key', cookie_expiry_days=30
)
Signed-off-by: Alexandre Duverger [email protected]