Junaidb commited on
Commit
2d80150
·
verified ·
1 Parent(s): 3264ba3

Create auth.py

Browse files
Files changed (1) hide show
  1. auth.py +16 -0
auth.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yaml
2
+ from yaml.loader import SafeLoader
3
+ import streamlit_authenticator as stauth
4
+
5
+ # Load config from YAML
6
+ with open('config.yaml') as file:
7
+ config = yaml.load(file, Loader=SafeLoader)
8
+
9
+ # Define the authenticator
10
+ authenticator = stauth.Authenticate(
11
+ config['credentials'], # contains usernames/passwords
12
+ config['cookie']['name'], # name of the login session cookie
13
+ config['cookie']['key'], # secret key for signing the cookie
14
+ config['cookie']['expiry_days'],
15
+ config['preauthorized'] # email whitelist
16
+ )