mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-05-13 19:38:45 +02:00
Slimmed down the env vars access and added logging in case the password protection was disabled. (#252)
Slimmed down the env vars access and added logging in case the password protection was disabled.
This commit is contained in:
parent
55ebb4c17d
commit
88f0673470
@ -12,8 +12,13 @@ def add_auth(app: Dash) -> None:
|
||||
Args:
|
||||
app: The app a basic auth should be added to.
|
||||
"""
|
||||
if os.getenv("PYTHON_DASH_LOGIN_USERNAME") and os.getenv("PYTHON_DASH_LOGIN_PW"):
|
||||
login = os.getenv("PYTHON_DASH_LOGIN_USERNAME")
|
||||
pw = os.getenv("PYTHON_DASH_LOGIN_PW")
|
||||
if (login := os.getenv("PYTHON_DASH_LOGIN_USERNAME", None)) and (
|
||||
pw := os.getenv("PYTHON_DASH_LOGIN_PW", None)
|
||||
):
|
||||
logger.info("Staring app in password protected mode!")
|
||||
dash_auth.BasicAuth(app, {login: pw})
|
||||
return
|
||||
logger.info("The password protection is not or only partially configured!")
|
||||
logger.debug(
|
||||
"The enviromental variables PYTHON_DASH_LOGIN_USERNAME and PYTHON_DASH_LOGIN_PW should be used to activate this feature."
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user