api: restructure user authentication modelling to support other user backends
All checks were successful
Build Container / Build Container (push) Successful in 1m26s
All checks were successful
Build Container / Build Container (push) Successful in 1m26s
This commit is contained in:
parent
e5b880d038
commit
63a9485209
4 changed files with 99 additions and 58 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import os
|
||||
import sys
|
||||
import logging
|
||||
from contextvars import ContextVar
|
||||
from argparse import ArgumentParser, Namespace
|
||||
|
|
@ -51,7 +50,9 @@ def main():
|
|||
argp.add_argument(
|
||||
"--ccujack-url",
|
||||
required=False,
|
||||
default=os.environ.get("DOORIS_CCUJACK_URL", "https://hmdooris-ccu.ccchh.net:2122"),
|
||||
default=os.environ.get(
|
||||
"DOORIS_CCUJACK_URL", "https://hmdooris-ccu.ccchh.net:2122"
|
||||
),
|
||||
help="The URL under which a CCUJACK instance is hosted that actually operates the locks",
|
||||
)
|
||||
argp.add_argument(
|
||||
|
|
@ -70,12 +71,21 @@ def main():
|
|||
"--ccujack-password",
|
||||
required="DOORIS_CCUJACK_PASSWORD" not in os.environ,
|
||||
default=os.environ.get("DOORIS_CCUJACK_PASSWORD", None),
|
||||
help="The password used to authenticate against the CCUJACK"
|
||||
help="The password used to authenticate against the CCUJACK",
|
||||
)
|
||||
argp.add_argument(
|
||||
"--static-api-tokens",
|
||||
required=False,
|
||||
nargs=1,
|
||||
action="append",
|
||||
default=[],
|
||||
)
|
||||
args = argp.parse_args()
|
||||
|
||||
# setup logging
|
||||
logging.basicConfig(level=logging.DEBUG, format="[%(levelname)s] %(filename)s: %(message)s")
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG, format="[%(levelname)s] %(filename)s: %(message)s"
|
||||
)
|
||||
|
||||
# setup app
|
||||
app_config.set(args)
|
||||
|
|
@ -84,8 +94,11 @@ def main():
|
|||
|
||||
if args.serve_static:
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
app.mount("/", StaticFiles(directory=args.serve_static, html=True), name="static")
|
||||
|
||||
|
||||
app.mount(
|
||||
"/", StaticFiles(directory=args.serve_static, html=True), name="static"
|
||||
)
|
||||
|
||||
# start webserver
|
||||
config = uvicorn.Config(app, port=8000, log_level="debug")
|
||||
server = uvicorn.Server(config)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue