From 8f456802df69a1c17ed35134893ff2027d63036f Mon Sep 17 00:00:00 2001 From: David Brochart Date: Mon, 29 Aug 2022 21:58:26 +0200 Subject: [PATCH] Open browser window with token as query parameter --- plugins/auth/fps_auth/routes.py | 8 +++++--- plugins/auth/setup.cfg | 2 +- setup.cfg | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/auth/fps_auth/routes.py b/plugins/auth/fps_auth/routes.py index a75de8a6..91c8e1dd 100644 --- a/plugins/auth/fps_auth/routes.py +++ b/plugins/auth/fps_auth/routes.py @@ -6,6 +6,7 @@ from fps.config import get_config # type: ignore from fps.hooks import register_router # type: ignore from fps.logging import get_configured_logger # type: ignore +from fps_uvicorn.cli import add_query_params # type: ignore from fps_uvicorn.config import UvicornConfig # type: ignore from sqlalchemy import select # type: ignore @@ -30,7 +31,9 @@ logger = get_configured_logger("auth") -uvicorn_config = get_config(UvicornConfig) +auth_config = get_auth_config() +if auth_config.mode == "token": + add_query_params({"token": auth_config.token}) router = APIRouter() @@ -67,8 +70,6 @@ async def get_user_by_email(user_email): async def startup(): await create_db_and_tables() - auth_config = get_auth_config() - if auth_config.test: try: await create_user( @@ -96,6 +97,7 @@ async def startup(): ) if auth_config.mode == "token": + uvicorn_config = get_config(UvicornConfig) logger.info("") logger.info("To access the server, copy and paste this URL:") logger.info( diff --git a/plugins/auth/setup.cfg b/plugins/auth/setup.cfg index 93248ca3..13d9f834 100644 --- a/plugins/auth/setup.cfg +++ b/plugins/auth/setup.cfg @@ -20,7 +20,7 @@ packages = find: python_requires = >=3.7 install_requires = - fps >=0.0.8 + fps[uvicorn] >=0.0.17 fps-lab aiosqlite fastapi-users[sqlalchemy,oauth] >=10.1.4,<11 diff --git a/setup.cfg b/setup.cfg index a55a4f96..6bbd83c2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,7 +22,7 @@ package_dir = python_requires = >=3.7 install_requires = - fps[uvicorn] >=0.0.10 + fps[uvicorn] >=0.0.17 fps-login fps-auth fps-contents