From cb04f91b45792e2f20579927105ec942752cc9a3 Mon Sep 17 00:00:00 2001 From: kaushik327 Date: Thu, 4 Apr 2024 18:25:53 -0500 Subject: [PATCH] make authorizer raise exception --- backend/auth/authorizer.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/backend/auth/authorizer.py b/backend/auth/authorizer.py index 1a5c3d9..f9b5966 100644 --- a/backend/auth/authorizer.py +++ b/backend/auth/authorizer.py @@ -2,7 +2,6 @@ from auth_utils import AuthPolicy import json import requests -from msal import ConfidentialClientApplication def lambda_handler(event, context): """Do not print the auth token unless absolutely necessary """ @@ -43,20 +42,13 @@ def lambda_handler(event, context): print("User is a member of the group.") policy.allowAllMethods() elif response.status_code == 404: - print("User is not a member of the group.") + raise Exception('Unauthorized') else: - print("Error occurred while checking group membership.") - #policy.allowAllMethods() # For now just let anyone in lol + # TODO: this returns a 500 error I think? is there a better way to do this + return "Error occurred while checking group membership." # Finally, build the policy authResponse = policy.build() print("Auth response: " + json.dumps(authResponse, indent=4)) - - # context = { - # 'key': 'value', # $context.authorizer.key -> value - # 'number' : 1, - # 'bool' : True - # } - # authResponse['context'] = context return authResponse \ No newline at end of file