TherapyNote / config /auth.py
abagherp's picture
Upload folder using huggingface_hub
6830eb0 verified
raw
history blame contribute delete
786 Bytes
from __future__ import annotations
import os
from pathlib import Path
import yaml
from typing import Dict
def load_auth_credentials() -> Dict[str, str]:
"""Load authentication credentials from YAML file."""
auth_file = Path("config/credentials.yaml")
if not auth_file.exists():
# Create default credentials file if it doesn't exist
default_auth = {
"credentials": {
"admin": os.environ.get("ADMIN_PASSWORD", "change_this_password"),
}
}
auth_file.parent.mkdir(parents=True, exist_ok=True)
with open(auth_file, "w") as f:
yaml.dump(default_auth, f)
with open(auth_file, "r") as f:
auth_data = yaml.safe_load(f)
return auth_data.get("credentials", {})