api: configure ccujack connection via established config mechanism
This commit is contained in:
parent
cb570a7663
commit
f72f830b36
3 changed files with 21 additions and 2 deletions
1
.dev.env
1
.dev.env
|
|
@ -2,3 +2,4 @@ DOORIS_OPENID_ISSUER=https://id.hamburg.ccc.de/realms/test/
|
|||
DOORIS_OPENID_CLIENT_ID=dooris
|
||||
DOORIS_OPENID_CLIENT_SECRET=dp9HhnvUhAtKm3pRnxfGA7q8Nwrd1td8
|
||||
DOORIS_BASE_URL=http://localhost:8000
|
||||
DOORIS_CCUJACK_USER=dooris
|
||||
|
|
|
|||
|
|
@ -46,6 +46,24 @@ def main():
|
|||
default=os.environ.get("DOORIS_SERVE_STATIC", None),
|
||||
help="In addition to the API functionality, serve static files from this path",
|
||||
)
|
||||
argp.add_argument(
|
||||
"--ccujack-url",
|
||||
required=False,
|
||||
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(
|
||||
"--ccujack-user",
|
||||
required="DOORIS_CCUJACK_USER" not in os.environ,
|
||||
default=os.environ.get("DOORIS_CCUJACK_USER", None),
|
||||
help="The username used to authenticate against the CCUJACK",
|
||||
)
|
||||
argp.add_argument(
|
||||
"--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"
|
||||
)
|
||||
args = argp.parse_args()
|
||||
|
||||
app_config.set(args)
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@ async def lifespan(app: FastAPI):
|
|||
)
|
||||
|
||||
app.extra["ccujack"] = CCUJackClient(
|
||||
"https://hmdooris-ccu.ccchh.net:2122",
|
||||
auth=BasicAuth("dooris", os.environ["HMDOORIS_PW"]),
|
||||
base_uri=app_cfg.ccujack_url,
|
||||
auth=BasicAuth(app_cfg.ccujack_user, app_cfg.ccujack_password)
|
||||
)
|
||||
await app.extra["ccujack"].find_locks()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue