From cb16822dc908f98c52a0197de0fc1291c81f440d Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Sun, 7 Jan 2024 15:37:10 +0000 Subject: [PATCH] add auth state and log auth state --- jhub_apps/service/models.py | 1 + jhub_apps/service/service.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/jhub_apps/service/models.py b/jhub_apps/service/models.py index e7f63b50..125baf84 100644 --- a/jhub_apps/service/models.py +++ b/jhub_apps/service/models.py @@ -29,6 +29,7 @@ class User(BaseModel): last_activity: Optional[datetime] = None servers: Optional[Dict[str, Server]] = None scopes: List[str] + auth_state: Optional[Dict] = None # https://stackoverflow.com/questions/64501193/fastapi-how-to-use-httpexception-in-responses diff --git a/jhub_apps/service/service.py b/jhub_apps/service/service.py index be099fb3..7f25b3be 100644 --- a/jhub_apps/service/service.py +++ b/jhub_apps/service/service.py @@ -227,7 +227,7 @@ async def get_frameworks(user: User = Depends(get_current_user)): @router.get("/conda-environments/", description="Get all conda environments") async def conda_environments(user: User = Depends(get_current_user)): - logging.info("Getting conda environments") + logging.info(f"Getting conda environments for user: {user}") config = get_jupyterhub_config() conda_envs = get_conda_envs(config) return conda_envs @@ -235,7 +235,7 @@ async def conda_environments(user: User = Depends(get_current_user)): @router.get("/spawner-profiles/", description="Get all spawner profiles") async def spawner_profiles(user: User = Depends(get_current_user)): - logging.info("Getting spawner profiles") + logging.info(f"Getting spawner profiles for user: {user}") config = get_jupyterhub_config() spawner_profiles_ = await get_spawner_profiles(config) logger.info(f"Loaded spawner profiles: {config}") @@ -244,7 +244,7 @@ async def spawner_profiles(user: User = Depends(get_current_user)): @router.get("/services/", description="Get all services") async def hub_services(user: User = Depends(get_current_user)): - logging.info("Getting hub services") + logging.info(f"Getting hub services for user: {user}") hub_client = HubClient() return hub_client.get_services()