Skip to content

Commit

Permalink
fix tests and ignore google-iap if not configured
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Jan 16, 2024
1 parent 9c1e09e commit 7494b2c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions plugins/quetz_googleiap/quetz_googleiap/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class GoogleIAMMiddleware(BaseHTTPMiddleware):
def __init__(self, app, config: Config):
if config is not None:
self.configure(config)
self.last_checked = dict()
else:
self.configured = False

super().__init__(app)

def configure(self, config: Config):
Expand All @@ -46,10 +48,18 @@ def configure(self, config: Config):
# load configuration values
if config.configured_section("googleiam"):
self.server_admin_emails = config.googleiam_server_admin_emails
logger.info("Google IAM successfully configured")
logger.info(f"Google IAM server admin emails: {self.server_admin_emails}")
self.configured = True
else:
raise Exception("Google IAM is not configured")
self.configured = False

async def dispatch(self, request, call_next):
# ignore middleware if it is not configured
if not self.configured:
response = await call_next(request)
return response

# Check if the session has a specific key, for example 'count'.
# If it does, increment its value. If it doesn't, set it to 1.
count = request.session.get("count", 0)
Expand Down

0 comments on commit 7494b2c

Please sign in to comment.