Files
testing123/streamlit_dashboard/auth_config_loader.py
2026-05-21 08:40:24 -04:00

20 lines
628 B
Python

import yaml
from streamlit_authenticator import Authenticate
from yaml.loader import SafeLoader
import streamlit_authenticator as stauth
def load_auth_config(config_path) -> Authenticate:
try:
with open(config_path) as file:
config = yaml.load(file, Loader=SafeLoader)
authenticator = stauth.Authenticate(
config['credentials'],
config['cookie']['name'],
config['cookie']['key'],
config['cookie']['expiry_days'],
auto_hash = True
)
return authenticator
except FileNotFoundError:
return None #pyright:ignore