From c29b0d0289b4a3a14654a89130f535d1419bbfd2 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Wed, 6 Dec 2023 17:42:48 +0100 Subject: [PATCH] fix lint --- .../quetz_googleiap/middleware.py | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/plugins/quetz_googleiap/quetz_googleiap/middleware.py b/plugins/quetz_googleiap/quetz_googleiap/middleware.py index 5f80ebb1..52829f50 100644 --- a/plugins/quetz_googleiap/quetz_googleiap/middleware.py +++ b/plugins/quetz_googleiap/quetz_googleiap/middleware.py @@ -1,22 +1,17 @@ +import logging +import uuid + from starlette.middleware.base import BaseHTTPMiddleware -from quetz.config import Config, ConfigEntry, ConfigSection import quetz.authentication.base as auth_base - -from quetz.dao import Dao from quetz import rest_models +from quetz.config import Config, ConfigEntry, ConfigSection +from quetz.dao import Dao +from quetz.deps import get_config, get_db -from quetz.deps import ( - get_config, - get_db, -) - -import uuid -import datetime - -import logging logger = logging.getLogger("quetz.googleiam") + def email_to_channel_name(email): name = email.split("@")[0] name = name.replace(".", "-") @@ -29,6 +24,7 @@ class GoogleIAMMiddleware(BaseHTTPMiddleware): Handles Google IAM headers and authorizes users based on the Google IAM headers. """ + def __init__(self, app, config: Config): if config is not None: self.configure(config) @@ -105,7 +101,7 @@ async def dispatch(self, request, call_next): def google_role_for_user(self, user_id, dao): if not user_id: return - + if user_id in self.server_admin_emails: logger.info(f"User {user_id} is server admin") dao.set_user_role(user_id, "owner") @@ -115,4 +111,4 @@ def google_role_for_user(self, user_id, dao): def middleware(): - return GoogleIAMMiddleware \ No newline at end of file + return GoogleIAMMiddleware