diff --git a/auth/login.py b/auth/login.py index 4aecf71..7b60892 100644 --- a/auth/login.py +++ b/auth/login.py @@ -3,13 +3,20 @@ import logging from fastapi.responses import RedirectResponse from nicegui import APIRouter, app, ui -from auth.fakeldap import get_data +from state import config log = logging.getLogger(__name__) router = APIRouter() +if config.fake: + log.warning("using fake LDAP") + from auth.fakeldap import get_data +else: + from auth.psildap import get_data + + @router.page("/login") def login(redirect_to: str = "/") -> RedirectResponse | None: if app.storage.user.get("authenticated"): diff --git a/cli.py b/cli.py new file mode 100644 index 0000000..77532b4 --- /dev/null +++ b/cli.py @@ -0,0 +1,11 @@ +import argparse + + +parser = argparse.ArgumentParser() + +parser.add_argument("-f", "--fake", action="store_true") + +clargs = parser.parse_args() + + + diff --git a/config.py b/config.py new file mode 100644 index 0000000..788d7d7 --- /dev/null +++ b/config.py @@ -0,0 +1,8 @@ + +class Config(dict): + __getattr__ = dict.__getitem__ + __setattr__ = dict.__setitem__ + __delattr__ = dict.__delitem__ + + + diff --git a/stand.py b/stand.py index 54a27ed..c0e97e6 100755 --- a/stand.py +++ b/stand.py @@ -2,6 +2,10 @@ from nicegui import app, ui +from cli import clargs +from state import config +config.update(vars(clargs)) + from logcfg import logcfg logcfg() diff --git a/state.py b/state.py index 7a66bf9..d07af00 100644 --- a/state.py +++ b/state.py @@ -2,6 +2,7 @@ from collections import defaultdict import arcticdb as adb +from config import Config from registry import Registry @@ -15,6 +16,11 @@ lib = ac.get_library( ) +config = Config( + fake=False +) + + grids = defaultdict(Registry)