From 866f33185f1746d61f9286fea880e65035c4ddd8 Mon Sep 17 00:00:00 2001 From: adarshk-5 Date: Fri, 1 Dec 2023 18:28:10 -0600 Subject: [PATCH 01/51] create_user function --- .DS_Store | Bin 8196 -> 8196 bytes backend/create_user.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 backend/create_user.py diff --git a/.DS_Store b/.DS_Store index 50c1363860440f6af0dc0ca1d7c564732da94458..4a4654ca70968cb9522deef5f02b057cf4b95068 100644 GIT binary patch delta 303 zcmZp1XmOa}&nUMsU^hRb+-4pDKNgOZ;^ds9{QR8BjKZ3eqeS@Y*%^`;5*d;ivKdkt z@)%NJ@(e(LCY6(J7@VA+TL6-R0yGu5`7SO=Ir&LIS&pTx2el%4k2(U`7^+ebsw8nL mn`|d$u(?e{ff3>6g(8ZZmx;zOZf2MG#$t-kSkg_6WCQ?LluqgZ delta 63 zcmZp1XmOa}&nUhzU^hRb_+}mfKbFbeBK(s-iOFtG5>;T_yjm=Vabp83<7Re=Z!D9m O1zab~iKReAnHT|zIutJe diff --git a/backend/create_user.py b/backend/create_user.py new file mode 100644 index 0000000..560d8ff --- /dev/null +++ b/backend/create_user.py @@ -0,0 +1,29 @@ +import json +import boto3 + +dynamodb = boto3.resource('dynamodb', region_name = 'us-east-1') +table = dynamodb.Table('infra-admin-api') + +def create_user(netid, roleStr, permStr): + netid = netid.strip() + + roles = roleStr.split(",") + roles = [x.strip() for x in roles] + + perms = permStr.split(",") + perms = [x.strip() for x in perms] + + user = { + "netid": netid, + "roles": roles, + "permissions": perms + } + + user_json = json.loads(json.dumps(user, indent=4)) + + response = table.put_item( + Item={ + "netid": netid, + "value": user_json + } + ) From 3739853769d89cbfaf659e828b03f6eb610bd564 Mon Sep 17 00:00:00 2001 From: adarshk-5 Date: Fri, 1 Dec 2023 18:56:24 -0600 Subject: [PATCH 02/51] user functions file --- .DS_Store | Bin 8196 -> 8196 bytes backend/.DS_Store | Bin 0 -> 6148 bytes backend/{create_user.py => user_funs.py} | 24 +++++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 backend/.DS_Store rename backend/{create_user.py => user_funs.py} (54%) diff --git a/.DS_Store b/.DS_Store index 4a4654ca70968cb9522deef5f02b057cf4b95068..8ad8fca0587a02012438fe8948965c24dbf81563 100644 GIT binary patch delta 14 VcmZp1XmQxEQG}6k^CpoXZU8851l9lm delta 14 VcmZp1XmQxEQG}6U^CpoXZU87~1l0fl diff --git a/backend/.DS_Store b/backend/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Sat, 2 Dec 2023 11:32:03 -0600 Subject: [PATCH 03/51] Update user_funs.py added rudimentary update_user function --- backend/user_funs.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/backend/user_funs.py b/backend/user_funs.py index 2b4be41..1d19ca6 100644 --- a/backend/user_funs.py +++ b/backend/user_funs.py @@ -35,7 +35,35 @@ def get_user(netid): def delete_user(netid): response = table.delete_item(Key={"netid": netid}) -#def modify_user(netid, newRoles, newPerms): +def update_user(netid, newRoles, newPerms): + if (get_user(netid) == "Does Not Exist"): + return "User does not exist" + + nRoles = newRoles.split(",") + nRoles = [x.strip() for x in nRoles] + nRoles = get_user(netid).get("value").get("roles") + nRoles + + nPerms = newPerms.split(",") + nPerms = [x.strip() for x in nPerms] + nPerms = get_user(netid).get("value").get("permissions") + nPerms + + user = { + "netid": netid, + "roles": nRoles, + "permissions": nPerms + } + + user_json = json.loads(json.dumps(user, indent=4)) + + response = table.update_item( + Key={"netid": netid}, + AttributeUpdates={"value": + {"Value": user_json, + "Action": "PUT"} + } + ) + + return get_user(netid) if __name__ == "__main__": netid = input("netid: ") @@ -46,8 +74,12 @@ def delete_user(netid): print(f"getting user: {get_user(netid)}") + print(f"updating user: {update_user(netid, '11, 22', ' 22 , 11 ')}") + print("deleting user") delete_user(netid) print(f"getting user: {get_user(netid)}") + + print(f"updating user: {update_user(netid, '11, 22', ' 22 , 11 ')}") From 935a4ce720ecc77f8c13e86ed00609888cb56034 Mon Sep 17 00:00:00 2001 From: adarshk-5 Date: Fri, 26 Jan 2024 21:27:05 -0600 Subject: [PATCH 04/51] Separate function files Moved each function in user_funs to a separate function file --- backend/create_user.py | 29 +++++++++++++++++++++++++++++ backend/delete_user.py | 8 ++++++++ backend/get_user.py | 9 +++++++++ backend/update_user.py | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 backend/create_user.py create mode 100644 backend/delete_user.py create mode 100644 backend/get_user.py create mode 100644 backend/update_user.py diff --git a/backend/create_user.py b/backend/create_user.py new file mode 100644 index 0000000..560d8ff --- /dev/null +++ b/backend/create_user.py @@ -0,0 +1,29 @@ +import json +import boto3 + +dynamodb = boto3.resource('dynamodb', region_name = 'us-east-1') +table = dynamodb.Table('infra-admin-api') + +def create_user(netid, roleStr, permStr): + netid = netid.strip() + + roles = roleStr.split(",") + roles = [x.strip() for x in roles] + + perms = permStr.split(",") + perms = [x.strip() for x in perms] + + user = { + "netid": netid, + "roles": roles, + "permissions": perms + } + + user_json = json.loads(json.dumps(user, indent=4)) + + response = table.put_item( + Item={ + "netid": netid, + "value": user_json + } + ) diff --git a/backend/delete_user.py b/backend/delete_user.py new file mode 100644 index 0000000..992a0cf --- /dev/null +++ b/backend/delete_user.py @@ -0,0 +1,8 @@ +import json +import boto3 + +dynamodb = boto3.resource('dynamodb', region_name = 'us-east-1') +table = dynamodb.Table('infra-admin-api') + +def delete_user(netid): + response = table.delete_item(Key={"netid": netid}) diff --git a/backend/get_user.py b/backend/get_user.py new file mode 100644 index 0000000..66d174d --- /dev/null +++ b/backend/get_user.py @@ -0,0 +1,9 @@ +import json +import boto3 + +dynamodb = boto3.resource('dynamodb', region_name = 'us-east-1') +table = dynamodb.Table('infra-admin-api') + +def get_user(netid): + response = table.get_item(Key={"netid": netid}) + return response.get("Item", "Does Not Exist") diff --git a/backend/update_user.py b/backend/update_user.py new file mode 100644 index 0000000..4caf613 --- /dev/null +++ b/backend/update_user.py @@ -0,0 +1,35 @@ +import json +import boto3 + +dynamodb = boto3.resource('dynamodb', region_name = 'us-east-1') +table = dynamodb.Table('infra-admin-api') + +def update_user(netid, newRoles, newPerms): + if (get_user(netid) == "Does Not Exist"): + return "User does not exist" + + nRoles = newRoles.split(",") + nRoles = [x.strip() for x in nRoles] + nRoles = get_user(netid).get("value").get("roles") + nRoles + + nPerms = newPerms.split(",") + nPerms = [x.strip() for x in nPerms] + nPerms = get_user(netid).get("value").get("permissions") + nPerms + + user = { + "netid": netid, + "roles": nRoles, + "permissions": nPerms + } + + user_json = json.loads(json.dumps(user, indent=4)) + + response = table.update_item( + Key={"netid": netid}, + AttributeUpdates={"value": + {"Value": user_json, + "Action": "PUT"} + } + ) + + return get_user(netid) From 768f058cde6fe6f6fa5e8f6832cd9f04cb80bdb5 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Fri, 26 Jan 2024 22:19:08 -0600 Subject: [PATCH 05/51] Began updating lambda.yml --- cloudformation/lambda.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 522dfac..c32f0bc 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -18,6 +18,16 @@ Resources: WriteCapacityUnits: 1 PointInTimeRecoverySpecification: PointInTimeRecoveryEnabled: true + create_user: + Type: AWS::Lambda::Function + Properties: + Role: arn:aws:iam::123456789012:role/lambda-role + Code: + S3Bucket: #??? + S3Key: #??? + ZipFile: backend/create_user.py + Timeout: 5 + #Before adding more functions, it would be helpful to know what properties the function should have Outputs: DynamoDBTableName: From cd9167fe6eaa6229ed53450f3f8035bc2febfbcd Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 1 Feb 2024 18:01:16 -0600 Subject: [PATCH 06/51] Add User Management Lambda Function --- cloudformation/lambda.yml | 74 +++++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 7 deletions(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index c32f0bc..bd38258 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -18,16 +18,76 @@ Resources: WriteCapacityUnits: 1 PointInTimeRecoverySpecification: PointInTimeRecoveryEnabled: true - create_user: + + AdminAPIUserManagementLambda: Type: AWS::Lambda::Function Properties: - Role: arn:aws:iam::123456789012:role/lambda-role - Code: - S3Bucket: #??? - S3Key: #??? - ZipFile: backend/create_user.py + CodeUri: ../backend/user_funs.py + AutoPublishAlias: live + Runtime: python3.10 + Description: User Management Lambda + FunctionName: !Ref UserManagementLambda + Handler: api.lambda_handler + MemorySize: 2048 + Role: !GetAtt AdminAPIUserManagementLambdaIAMRole.Arn Timeout: 5 - #Before adding more functions, it would be helpful to know what properties the function should have + + AdminAPIUserManagementLambdaFunctionErrorAlarm: + Type: 'AWS::Cloudwatch::Alarm' + Condition: IsProd + Properties: + AlarmName: !Sub '${UserManagementLambda}-alarm' + AlarmDescription: !Sub 'Alarm if ${UserManagementLambda} function errors are detected.' + Namespace: 'AWS/Lambda' + MetricName: 'Errors' + Statistic: 'Sum' + Period: '60' + EvaluationPeriods: '1' + ComparisonOperator: 'GreaterThanThreshold' + Threshold: '0' + AlarmActions: + - !Ref AlertSNSArn + Dimensions: + - Name: 'FunctionName' + Value: !Ref UserManagementLambda + + AdminAPIUserManagementLambdaIAMRole: + Type: AWS::IAM::Role + Properties: + AssumeRolePolicyDocument: + Version: 2012-10-17 + Statement: + - Action: + - sts:AssumeRole + Effect: Allow + Principal: + Service: + - lambda.amazonaws.com + Policies: + - PolicyDocument: + Version: 2012-10-17 + Statement: + - Action: + - logs:CreateLogGroup + - logs:CreateLogStream + - logs:PutLogEvents + Effect: Allow + Resource: + - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/${UserManagementLambda}:* + PolicyName: lambda + - PolicyDocument: + Version: 2012-10-17 + Statement: + - Action: + - dynamodb:GetItem + - dynamodb:Scan + - dynamodb:UpdateItem + Effect: Allow + Resource: + - !GetAtt ItemsDynamoTable.Arn + - !GetAtt PurchasesDynamoTable.Arn + PolicyName: lambda-dynamo + Outputs: DynamoDBTableName: From b5e0d6221874f0dca6a67f96ddd689c4d8f13550 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 1 Feb 2024 18:04:46 -0600 Subject: [PATCH 07/51] Added conditions --- cloudformation/lambda.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index bd38258..a9b8cc9 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -2,6 +2,10 @@ AWSTemplateFormatVersion: '2010-09-09' Description: CloudFormation Template for DynamoDB Table Transform: AWS::Serverless-2016-10-31 +Conditions: + UseCustomDomainNameCond: !Equals [!Ref UseCustomDomainName, true] + IsProd: !Equals [!Ref Env, 'prod'] + Resources: MyDynamoDBTable: Type: AWS::DynamoDB::Table From 04753cd8320b7f1a340e8ed2eb84d096bb370969 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 1 Feb 2024 18:07:54 -0600 Subject: [PATCH 08/51] Added parameters --- cloudformation/lambda.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index a9b8cc9..db72dbd 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -2,6 +2,17 @@ AWSTemplateFormatVersion: '2010-09-09' Description: CloudFormation Template for DynamoDB Table Transform: AWS::Serverless-2016-10-31 +Parameters: + Env: + Description: Environment + Type: String + AllowedValues: [ 'dev', 'prod' ] + + UseCustomDomainName: + Type: String + Default: true + AllowedValues: [ true, false ] + Conditions: UseCustomDomainNameCond: !Equals [!Ref UseCustomDomainName, true] IsProd: !Equals [!Ref Env, 'prod'] From 2e1b90c328e0372c3b15c205098bc21a226f961d Mon Sep 17 00:00:00 2001 From: kaushik Date: Thu, 1 Feb 2024 18:12:36 -0600 Subject: [PATCH 09/51] add parameter overrides to deploy-dev.sh --- deploy-dev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy-dev.sh b/deploy-dev.sh index 0ceab30..734285c 100644 --- a/deploy-dev.sh +++ b/deploy-dev.sh @@ -1,3 +1,3 @@ #!/bin/bash sam build --template-file cloudformation/lambda.yml -sam deploy --no-confirm-changeset --no-fail-on-empty-changeset +sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --parameter-overrides ParameterKey=UseCustomDomainName,ParameterValue=false ParameterKey=Env,ParameterValue=dev From 40cbf56062782b47754a4e65b22851fde8217403 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 1 Feb 2024 18:15:36 -0600 Subject: [PATCH 10/51] Added UserManagementLambda Parameter --- cloudformation/lambda.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index db72dbd..a5fc777 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -13,6 +13,12 @@ Parameters: Default: true AllowedValues: [ true, false ] + UserManagementLambda: + Type: String + AllowedPattern: ^[a-zA-Z0-9]+[a-zA-Z0-9-]+[a-zA-Z0-9]+$ + Default: infra-admin-api-user-management-lambda + + Conditions: UseCustomDomainNameCond: !Equals [!Ref UseCustomDomainName, true] IsProd: !Equals [!Ref Env, 'prod'] From ecc19f1a68f4fc4342130e84f7f78aba60813f41 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 1 Feb 2024 18:17:51 -0600 Subject: [PATCH 11/51] Figure out GetAtt table reference issue --- cloudformation/lambda.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index a5fc777..a38aa3d 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -105,8 +105,7 @@ Resources: - dynamodb:UpdateItem Effect: Allow Resource: - - !GetAtt ItemsDynamoTable.Arn - - !GetAtt PurchasesDynamoTable.Arn + - !GetAtt DynamoTable.Arn #Find right table name??? PolicyName: lambda-dynamo From 5c4b482acd39c60aafeeb0f03a824fa11db78d1c Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 1 Feb 2024 18:26:37 -0600 Subject: [PATCH 12/51] Update lambda.yml --- cloudformation/lambda.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index a38aa3d..b694c03 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -48,7 +48,7 @@ Resources: Runtime: python3.10 Description: User Management Lambda FunctionName: !Ref UserManagementLambda - Handler: api.lambda_handler + Handler: lambda_handler MemorySize: 2048 Role: !GetAtt AdminAPIUserManagementLambdaIAMRole.Arn Timeout: 5 @@ -105,7 +105,7 @@ Resources: - dynamodb:UpdateItem Effect: Allow Resource: - - !GetAtt DynamoTable.Arn #Find right table name??? + - !GetAtt MyDynamoDBTable.Arn PolicyName: lambda-dynamo From 5822add5a71d7aa9f80dd9ecd196428f2070a55e Mon Sep 17 00:00:00 2001 From: kaushik Date: Thu, 1 Feb 2024 18:26:39 -0600 Subject: [PATCH 13/51] todo: single event handler function --- backend/user_funs.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backend/user_funs.py b/backend/user_funs.py index 1d19ca6..b92a494 100644 --- a/backend/user_funs.py +++ b/backend/user_funs.py @@ -65,6 +65,20 @@ def update_user(netid, newRoles, newPerms): return get_user(netid) +def lambda_handler(event, context): + method = event['httpMethod'] + path = event['path'] + queryParams = event["queryStringParameters"] + if not queryParams: + queryParams = {} + print(f"INFO: Processing request: method {method}, path {path}.") + + ## TODO: map method and path to user functions + # if method == "" and path == "": + # return update_user... + # else if... + + if __name__ == "__main__": netid = input("netid: ") roles = input("roles: ") From 5c7b785494dbe42185d243a2d56bbab07debc3f6 Mon Sep 17 00:00:00 2001 From: jlevine18 Date: Thu, 1 Feb 2024 21:11:58 -0600 Subject: [PATCH 14/51] fix: cloudformation bad references --- cloudformation/lambda.yml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index b694c03..e459c39 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -8,12 +8,17 @@ Parameters: Type: String AllowedValues: [ 'dev', 'prod' ] + AlertSNSArn: + Description: SNS Queue to send alarm alerts to + Type: String + Default: arn:aws:sns:us-east-1:298118738376:infra-monitor-alerts + UseCustomDomainName: Type: String Default: true AllowedValues: [ true, false ] - UserManagementLambda: + UserManagementLambdaName: Type: String AllowedPattern: ^[a-zA-Z0-9]+[a-zA-Z0-9-]+[a-zA-Z0-9]+$ Default: infra-admin-api-user-management-lambda @@ -47,7 +52,7 @@ Resources: AutoPublishAlias: live Runtime: python3.10 Description: User Management Lambda - FunctionName: !Ref UserManagementLambda + FunctionName: !Ref UserManagementLambdaName Handler: lambda_handler MemorySize: 2048 Role: !GetAtt AdminAPIUserManagementLambdaIAMRole.Arn @@ -57,8 +62,8 @@ Resources: Type: 'AWS::Cloudwatch::Alarm' Condition: IsProd Properties: - AlarmName: !Sub '${UserManagementLambda}-alarm' - AlarmDescription: !Sub 'Alarm if ${UserManagementLambda} function errors are detected.' + AlarmName: !Sub '${UserManagementLambdaName}-alarm' + AlarmDescription: !Sub 'Alarm if ${UserManagementLambdaName} function errors are detected.' Namespace: 'AWS/Lambda' MetricName: 'Errors' Statistic: 'Sum' @@ -70,7 +75,7 @@ Resources: - !Ref AlertSNSArn Dimensions: - Name: 'FunctionName' - Value: !Ref UserManagementLambda + Value: !Ref AdminAPIUserManagementLambda AdminAPIUserManagementLambdaIAMRole: Type: AWS::IAM::Role @@ -94,7 +99,7 @@ Resources: - logs:PutLogEvents Effect: Allow Resource: - - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/${UserManagementLambda}:* + - !Sub arn:aws:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/${UserManagementLambdaName}:* PolicyName: lambda - PolicyDocument: Version: 2012-10-17 From 1ebe96fc3edaada89281a9c8e91e22f122b2cffa Mon Sep 17 00:00:00 2001 From: jlevine18 Date: Thu, 1 Feb 2024 21:19:10 -0600 Subject: [PATCH 15/51] fix: remove illegal attr --- cloudformation/lambda.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index e459c39..f185ebd 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -49,7 +49,6 @@ Resources: Type: AWS::Lambda::Function Properties: CodeUri: ../backend/user_funs.py - AutoPublishAlias: live Runtime: python3.10 Description: User Management Lambda FunctionName: !Ref UserManagementLambdaName From 801dd1b31246fbce8ae1e580d351ac425bf283dd Mon Sep 17 00:00:00 2001 From: jlevine18 Date: Thu, 1 Feb 2024 21:23:05 -0600 Subject: [PATCH 16/51] fix: type (?) --- cloudformation/lambda.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index f185ebd..0e6baad 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -46,9 +46,10 @@ Resources: PointInTimeRecoveryEnabled: true AdminAPIUserManagementLambda: - Type: AWS::Lambda::Function + Type: AWS::Serverless::Function Properties: CodeUri: ../backend/user_funs.py + AutoPublishAlias: live Runtime: python3.10 Description: User Management Lambda FunctionName: !Ref UserManagementLambdaName From 03a2f521a5618876fd3bf6224cc651843ca6722c Mon Sep 17 00:00:00 2001 From: jlevine18 Date: Thu, 1 Feb 2024 21:24:51 -0600 Subject: [PATCH 17/51] chore: rename what it shows up as in CF console --- cloudformation/lambda.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 0e6baad..151d9ab 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -1,5 +1,5 @@ AWSTemplateFormatVersion: '2010-09-09' -Description: CloudFormation Template for DynamoDB Table +Description: Admin API Backend Transform: AWS::Serverless-2016-10-31 Parameters: From 701cd11186661d3a3c39f4f7e69f2bbe12263428 Mon Sep 17 00:00:00 2001 From: jlevine18 Date: Thu, 1 Feb 2024 21:29:13 -0600 Subject: [PATCH 18/51] fix: code is a folder --- cloudformation/lambda.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 151d9ab..8dda5a8 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -48,7 +48,7 @@ Resources: AdminAPIUserManagementLambda: Type: AWS::Serverless::Function Properties: - CodeUri: ../backend/user_funs.py + CodeUri: ../backend AutoPublishAlias: live Runtime: python3.10 Description: User Management Lambda From e4932a62e75d11526556a08016243850d055c16b Mon Sep 17 00:00:00 2001 From: jlevine18 Date: Thu, 1 Feb 2024 21:36:56 -0600 Subject: [PATCH 19/51] fix: handler --- cloudformation/lambda.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 8dda5a8..26d5aab 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -53,7 +53,7 @@ Resources: Runtime: python3.10 Description: User Management Lambda FunctionName: !Ref UserManagementLambdaName - Handler: lambda_handler + Handler: user_funs.lambda_handler MemorySize: 2048 Role: !GetAtt AdminAPIUserManagementLambdaIAMRole.Arn Timeout: 5 From e9ab1f23a1d41208d1d84ecad71a2002a69606e8 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:27:47 -0600 Subject: [PATCH 20/51] Added API Gateway --- cloudformation/lambda.yml | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 26d5aab..a6f3c30 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -112,6 +112,61 @@ Resources: Resource: - !GetAtt MyDynamoDBTable.Arn PolicyName: lambda-dynamo + + AdminAPIGateway: + Type: AWS::Serverless::Api + DependsOn: + - AdminAPIUserManagementLambda + Properties: + Name: !Ref AdminAPIGWName + Description: Admin API Gateway + AlwaysDeploy: True + DefinitionBody: + Fn::Transform: + Name: AWS::Include + Parameters: + Location: ../docs/swagger.yml + Domain: !If [UseCustomDomainNameCond, {DomainName: !Ref CustomDomainName, CertificateArn: !Ref CustomCertificateArn}, !Ref 'AWS::NoValue'] + StageName: default + + AdminAPIGatewayLatencyAlarm: + Type: 'AWS::CloudWatch::Alarm' + Condition: IsProd + Properties: + AlarmName: !Sub '${AdminAPIGWName}-latency-alarm' + AlarmDescription: !Sub 'Alarm if ${AdminAPIGWName} API gateway latency is > 2s.' + Namespace: 'AWS/ApiGateway' + MetricName: 'Latency' + Statistic: 'Average' + Period: '60' + EvaluationPeriods: '1' + ComparisonOperator: 'GreaterThanThreshold' + Threshold: '2000' + AlarmActions: + - !Ref AlertSNSArn + Dimensions: + - Name: 'ApiName' + Value: !Ref AdminAPIGWName + + AdminAPIGateway5XXErrorAlarm: + Type: 'AWS::CloudWatch::Alarm' + Condition: IsProd + Properties: + AlarmName: !Sub '${AdminAPIGWName}-5XX-alarm' + AlarmDescription: !Sub 'Alarm if ${AdminAPIGWName} API gateway 5XX errors are detected.' + Namespace: 'AWS/ApiGateway' + MetricName: '5XXError' + Statistic: 'Average' + Period: '60' + EvaluationPeriods: '1' + ComparisonOperator: 'GreaterThanThreshold' + Threshold: '2' + AlarmActions: + - !Ref AlertSNSArn + Dimensions: + - Name: 'ApiName' + Value: !Ref AdminAPIGWName + Outputs: From 40633df147f4e99905b7607382a38485d7954e7e Mon Sep 17 00:00:00 2001 From: Jasmine Liu <107429627+jasminerliu@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:33:34 -0600 Subject: [PATCH 21/51] Create swagger.yml --- docs/swagger.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/swagger.yml diff --git a/docs/swagger.yml b/docs/swagger.yml new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/docs/swagger.yml @@ -0,0 +1 @@ + From 3e6541e958b10b807c59c4ef3c5885a37c70f468 Mon Sep 17 00:00:00 2001 From: Jasmine Liu <107429627+jasminerliu@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:57:33 -0600 Subject: [PATCH 22/51] Update swagger.yml addded everythign --- docs/swagger.yml | 181 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 181 insertions(+) diff --git a/docs/swagger.yml b/docs/swagger.yml index 8b13789..142e8e1 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -1 +1,182 @@ +openapi: 3.0.3 +info: + title: ACM UIUC Admin API + version: "1.0.0" + contact: + name: ACM Infrastructure Team + email: infra@acm.illinois.edu +servers: + - url: adminapi.acm.illinois.edu + + +paths: + /api/v1/healthz: + get: + summary: Ping the API + operationId: ping + + responses: + 200: + description: OK + + + x-amazon-apigateway-auth: + type: NONE + + x-amazon-apigateway-integration: + responses: + default: + statusCode: 200 + passthroughBehavior: when_no_match + httpMethod: POST + contentHandling: CONVERT_TO_TEXT + type: aws_proxy + uri: + Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations + + /api/v1/create_user: + get: + summary: Creates a user + operationId: createUser + parameters: + - in: query + name: netid + schema: + type: string + required: true + description: Users NetID + - in: query + name: roleStr + schema: + type: string + required: true + description: indicates role + - in: query + name: permStr + schema: + type: string + required: true + description: perms + + responses: + 200: + description: OK + + + x-amazon-apigateway-auth: + type: NONE + + x-amazon-apigateway-integration: + responses: + default: + statusCode: 200 + passthroughBehavior: when_no_match + httpMethod: POST + contentHandling: CONVERT_TO_TEXT + type: aws_proxy + uri: + Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations" + + /api/v1/get_user: + get: + summary: Get User + operationId: getUser + parameters: + - in: query + name: netid + schema: + type: string + required: true + description: Users NetID + + responses: + 200: + description: OK + + x-amazon-apigateway-auth: + type: NONE + + x-amazon-apigateway-integration: + responses: + default: + statusCode: 200 + passthroughBehavior: when_no_match + httpMethod: POST + contentHandling: CONVERT_TO_TEXT + type: aws_proxy + uri: + Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations" + + /api/v1/delete_user: + get: + summary: Deletes a User + operationId: deleteUser + parameters: + - in: query + name: netid + schema: + type: string + required: true + description: Users NetID + + responses: + 200: + description: OK + + x-amazon-apigateway-auth: + type: NONE + + x-amazon-apigateway-integration: + responses: + default: + statusCode: 200 + passthroughBehavior: when_no_match + httpMethod: POST + contentHandling: CONVERT_TO_TEXT + type: aws_proxy + uri: + Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations + + /api/v1/update_user: + get: + summary: updates existing user + operationId: updateUser + parameters: + - in: query + name: netid + schema: + type: string + required: true + description: Users NetID + - in: query + name: newRoles + schema: + type: string + required: true + description: updates with new role + - in: query + name: newPerms + schema: + type: string + required: true + description: updates with new permission + + responses: + 200: + description: OK + + x-amazon-apigateway-auth: + type: NONE + + x-amazon-apigateway-integration: + responses: + default: + statusCode: 200 + passthroughBehavior: when_no_match + httpMethod: POST + contentHandling: CONVERT_TO_TEXT + type: aws_proxy + uri: + Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations + From cf0481835508f152f06dca16d8c4a9599f1e7a89 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 8 Feb 2024 18:24:39 -0600 Subject: [PATCH 23/51] Add lambda handler + execute --- backend/user_funs.py | 49 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/backend/user_funs.py b/backend/user_funs.py index b92a494..64a4361 100644 --- a/backend/user_funs.py +++ b/backend/user_funs.py @@ -72,12 +72,53 @@ def lambda_handler(event, context): if not queryParams: queryParams = {} print(f"INFO: Processing request: method {method}, path {path}.") + try: + return execute(method, path, queryParams, event['requestContext']['authorizer']) + except KeyError: + return execute(method, path, queryParams, {}) + +def execute(method: str, path: str, queryParams: dict, context: dict) -> dict: + try: + func: function = find_handler[method][path] + return func(context, queryParams) + except KeyError as e: + print(f"ERROR: No handler found for method {method} and path {path}.") + return notImplemented(context, queryParams) + +def healthzHandler(context, queryParams): + return { + "statusCode": 200, + 'headers': {'Access-Control-Allow-Origin': '*'}, + "body": "UP" + } +def notImplemented(context, queryParams): + return { + "statusCode": 404, + 'headers': {'Access-Control-Allow-Origin': '*'}, + "body": "Method not implemented." + } +def serverError(message): + return { + "statusCode": 500, + 'headers': {'Access-Control-Allow-Origin': '*'}, + "body": f"An error occurred - {message}" + } +def badRequest(message): + return { + "statusCode": 400, + 'headers': {'Access-Control-Allow-Origin': '*'}, + "body": f"Bad request - {message}" + } - ## TODO: map method and path to user functions - # if method == "" and path == "": - # return update_user... - # else if... +def userManagementHandler(context, queryParams): + #todo +find_handler = { + "GET": { + "/api/v1/healthz": healthzHandler, + "/api/v1/create_user": userManagementHandler, + } +} if __name__ == "__main__": netid = input("netid: ") From fc02f8500d0d8ee1fb46f4e26896f7798261b352 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Mon, 12 Feb 2024 16:39:55 -0600 Subject: [PATCH 24/51] Added createUserHandler for /api/v1/create_user --- backend/user_funs.py | 63 ++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/backend/user_funs.py b/backend/user_funs.py index 64a4361..e218612 100644 --- a/backend/user_funs.py +++ b/backend/user_funs.py @@ -1,5 +1,5 @@ -import json -import boto3 +import json, boto3 +from decimal import Decimal dynamodb = boto3.resource('dynamodb', region_name = 'us-east-1') table = dynamodb.Table('infra-admin-api') @@ -65,18 +65,6 @@ def update_user(netid, newRoles, newPerms): return get_user(netid) -def lambda_handler(event, context): - method = event['httpMethod'] - path = event['path'] - queryParams = event["queryStringParameters"] - if not queryParams: - queryParams = {} - print(f"INFO: Processing request: method {method}, path {path}.") - try: - return execute(method, path, queryParams, event['requestContext']['authorizer']) - except KeyError: - return execute(method, path, queryParams, {}) - def execute(method: str, path: str, queryParams: dict, context: dict) -> dict: try: func: function = find_handler[method][path] @@ -110,16 +98,57 @@ def badRequest(message): "body": f"Bad request - {message}" } -def userManagementHandler(context, queryParams): - #todo +class DecimalEncoder(json.JSONEncoder): + def default(self, obj): + if isinstance(obj, Decimal): + return float(obj) + return json.JSONEncoder.default(self, obj) + +def createUserHandler(context, queryParams): + try: + netid = queryParams["netid"]; + roleStr = queryParams["roleStr"]; + permStr = queryParams["permStr"]; + except: + return { + 'statusCode': 404, + 'body': "No netid/roles/permissions provided", + 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'} + } + try: + create_user(netid, roleStr, permStr); + return { + 'statusCode': 200, + 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, + 'body': json.dumps(item, cls=DecimalEncoder) + } + except Exception as e: + print(e) + return { + 'statusCode': 500, 'body': json.dumps({'message', 'Error.'}), + 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, + } + find_handler = { "GET": { "/api/v1/healthz": healthzHandler, - "/api/v1/create_user": userManagementHandler, + "/api/v1/create_user": createUserHandler, } } +def lambda_handler(event, context): + method = event['httpMethod'] + path = event['path'] + queryParams = event["queryStringParameters"] + if not queryParams: + queryParams = {} + print(f"INFO: Processing request: method {method}, path {path}.") + try: + return execute(method, path, queryParams, event['requestContext']['authorizer']) + except KeyError: + return execute(method, path, queryParams, {}) + if __name__ == "__main__": netid = input("netid: ") roles = input("roles: ") From 7f21ebb01a51724a144a1205789f05b518c54736 Mon Sep 17 00:00:00 2001 From: PranjalChaitanya <44535826+PranjalChaitanya@users.noreply.github.com> Date: Thu, 15 Feb 2024 17:13:59 -0600 Subject: [PATCH 25/51] Update deploy-dev.sh --- deploy-dev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy-dev.sh b/deploy-dev.sh index 734285c..4f2e6e1 100644 --- a/deploy-dev.sh +++ b/deploy-dev.sh @@ -1,3 +1,3 @@ #!/bin/bash sam build --template-file cloudformation/lambda.yml -sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --parameter-overrides ParameterKey=UseCustomDomainName,ParameterValue=false ParameterKey=Env,ParameterValue=dev +sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --capabilities CAPABILITY_IAM --parameter-overrides ParameterKey=UseCustomDomainName,ParameterValue=false ParameterKey=Env,ParameterValue=dev From 52f3a38c2f817fce639ee7024830a81d1d0a5283 Mon Sep 17 00:00:00 2001 From: PranjalChaitanya <44535826+PranjalChaitanya@users.noreply.github.com> Date: Thu, 15 Feb 2024 17:22:47 -0600 Subject: [PATCH 26/51] Update swagger.yml --- docs/swagger.yml | 56 ++++++++++++++---------------------------------- 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/docs/swagger.yml b/docs/swagger.yml index 142e8e1..4c97c82 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -1,29 +1,23 @@ +--- openapi: 3.0.3 info: title: ACM UIUC Admin API - version: "1.0.0" + version: 1.0.0 contact: name: ACM Infrastructure Team email: infra@acm.illinois.edu - servers: - url: adminapi.acm.illinois.edu - - paths: /api/v1/healthz: get: summary: Ping the API operationId: ping - responses: - 200: + "200": description: OK - - x-amazon-apigateway-auth: type: NONE - x-amazon-apigateway-integration: responses: default: @@ -33,8 +27,7 @@ paths: contentHandling: CONVERT_TO_TEXT type: aws_proxy uri: - Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations - + Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations /api/v1/create_user: get: summary: Creates a user @@ -58,15 +51,11 @@ paths: type: string required: true description: perms - responses: - 200: + "200": description: OK - - x-amazon-apigateway-auth: type: NONE - x-amazon-apigateway-integration: responses: default: @@ -76,8 +65,7 @@ paths: contentHandling: CONVERT_TO_TEXT type: aws_proxy uri: - Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations" - + Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations /api/v1/get_user: get: summary: Get User @@ -89,14 +77,11 @@ paths: type: string required: true description: Users NetID - responses: - 200: + "200": description: OK - x-amazon-apigateway-auth: type: NONE - x-amazon-apigateway-integration: responses: default: @@ -106,8 +91,7 @@ paths: contentHandling: CONVERT_TO_TEXT type: aws_proxy uri: - Fn::Sub: "arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations" - + Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations /api/v1/delete_user: get: summary: Deletes a User @@ -119,14 +103,11 @@ paths: type: string required: true description: Users NetID - responses: - 200: + "200": description: OK - x-amazon-apigateway-auth: type: NONE - x-amazon-apigateway-integration: responses: default: @@ -136,8 +117,7 @@ paths: contentHandling: CONVERT_TO_TEXT type: aws_proxy uri: - Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations - + Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations /api/v1/update_user: get: summary: updates existing user @@ -156,19 +136,16 @@ paths: required: true description: updates with new role - in: query - name: newPerms - schema: + name: newPerms + schema: null type: string - required: true - description: updates with new permission - + required: true + description: updates with new permission responses: - 200: + "200": description: OK - x-amazon-apigateway-auth: type: NONE - x-amazon-apigateway-integration: responses: default: @@ -178,5 +155,4 @@ paths: contentHandling: CONVERT_TO_TEXT type: aws_proxy uri: - Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations - + Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations From f9ca4c04a3cede5aa126bfd6a5ff5f3e65dbde05 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 15 Feb 2024 17:26:41 -0600 Subject: [PATCH 27/51] Set UseCustomDomainCond to false --- cloudformation/lambda.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index a6f3c30..76ef788 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -25,7 +25,7 @@ Parameters: Conditions: - UseCustomDomainNameCond: !Equals [!Ref UseCustomDomainName, true] + UseCustomDomainNameCond: !Equals [!Ref UseCustomDomainName, false] IsProd: !Equals [!Ref Env, 'prod'] Resources: From 28ffd4769645db99d65fda4346e837f2724daff5 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 15 Feb 2024 17:28:25 -0600 Subject: [PATCH 28/51] Update lambda.yml --- cloudformation/lambda.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 76ef788..736ed46 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -15,7 +15,7 @@ Parameters: UseCustomDomainName: Type: String - Default: true + Default: false AllowedValues: [ true, false ] UserManagementLambdaName: @@ -25,7 +25,7 @@ Parameters: Conditions: - UseCustomDomainNameCond: !Equals [!Ref UseCustomDomainName, false] + UseCustomDomainNameCond: !Equals [!Ref UseCustomDomainName, true] IsProd: !Equals [!Ref Env, 'prod'] Resources: From f09a81f2f91594b2d4c6a3779d69b1554f36bd4e Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 15 Feb 2024 17:30:56 -0600 Subject: [PATCH 29/51] Commented out AdminAPIGateway Domain property --- cloudformation/lambda.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 736ed46..1ac4c5f 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -126,7 +126,7 @@ Resources: Name: AWS::Include Parameters: Location: ../docs/swagger.yml - Domain: !If [UseCustomDomainNameCond, {DomainName: !Ref CustomDomainName, CertificateArn: !Ref CustomCertificateArn}, !Ref 'AWS::NoValue'] + #Domain: !If [UseCustomDomainNameCond, {DomainName: !Ref CustomDomainName, CertificateArn: !Ref CustomCertificateArn}, !Ref 'AWS::NoValue'] StageName: default AdminAPIGatewayLatencyAlarm: From 11bd4bd5be908939f2a8b0b80c3a0e040b6f8f3c Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 15 Feb 2024 17:33:47 -0600 Subject: [PATCH 30/51] Update swagger.yml --- docs/swagger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/swagger.yml b/docs/swagger.yml index 4c97c82..6c45b9d 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -138,7 +138,7 @@ paths: - in: query name: newPerms schema: null - type: string + type: string required: true description: updates with new permission responses: From 52f78189564c483757acb56e145a6f82afcae85d Mon Sep 17 00:00:00 2001 From: kaushik Date: Thu, 15 Feb 2024 17:35:41 -0600 Subject: [PATCH 31/51] Update swagger.yml --- docs/swagger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/swagger.yml b/docs/swagger.yml index 6c45b9d..3b0441d 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -137,7 +137,7 @@ paths: description: updates with new role - in: query name: newPerms - schema: null + schema: type: string required: true description: updates with new permission From 88122377e9cb096c89261e10b0676086288976f5 Mon Sep 17 00:00:00 2001 From: PranjalChaitanya <44535826+PranjalChaitanya@users.noreply.github.com> Date: Thu, 15 Feb 2024 17:41:39 -0600 Subject: [PATCH 32/51] Update swagger.yml --- docs/swagger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/swagger.yml b/docs/swagger.yml index 3b0441d..6c45b9d 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -137,7 +137,7 @@ paths: description: updates with new role - in: query name: newPerms - schema: + schema: null type: string required: true description: updates with new permission From 95f8afff2d8e92f2fc1358579fa1172c18e9a2b7 Mon Sep 17 00:00:00 2001 From: PranjalChaitanya <44535826+PranjalChaitanya@users.noreply.github.com> Date: Thu, 15 Feb 2024 17:42:25 -0600 Subject: [PATCH 33/51] Update swagger.yml --- docs/swagger.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/swagger.yml b/docs/swagger.yml index 6c45b9d..3b0441d 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -137,7 +137,7 @@ paths: description: updates with new role - in: query name: newPerms - schema: null + schema: type: string required: true description: updates with new permission From 26dafdcf0c13399db23edef373795b5029bf6b69 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 15 Feb 2024 18:53:57 -0600 Subject: [PATCH 34/51] Added handler functions for remaining paths --- backend/user_funs.py | 75 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/backend/user_funs.py b/backend/user_funs.py index e218612..32fb822 100644 --- a/backend/user_funs.py +++ b/backend/user_funs.py @@ -128,12 +128,85 @@ def createUserHandler(context, queryParams): 'statusCode': 500, 'body': json.dumps({'message', 'Error.'}), 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, } - + +def getUserHandler(context, queryParams): + try: + netid = queryParams["netid"]; + except: + return { + 'statusCode': 404, + 'body': "No netid provided", + 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'} + } + try: + get_user(netid); + return { + 'statusCode': 200, + 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, + 'body': json.dumps(item, cls=DecimalEncoder) + } + except Exception as e: + print(e) + return { + 'statusCode': 500, 'body': json.dumps({'message', 'Error.'}), + 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, + } + +def deleteUserHandler(context, queryParams): + try: + netid = queryParams["netid"]; + except: + return { + 'statusCode': 404, + 'body': "No netid provided", + 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'} + } + try: + delete_user(netid); + return { + 'statusCode': 200, + 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, + 'body': json.dumps(item, cls=DecimalEncoder) + } + except Exception as e: + print(e) + return { + 'statusCode': 500, 'body': json.dumps({'message', 'Error.'}), + 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, + } + +def updateUserHandler(context, queryParams): + try: + netid = queryParams["netid"]; + newRoles = queryParams["newRoles"]; + newPerms = queryParams["newPerms"]; + except: + return { + 'statusCode': 404, + 'body': "No netid/roles/permissions provided", + 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'} + } + try: + update_user(netid, newRoles, newPerms); + return { + 'statusCode': 200, + 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, + 'body': json.dumps(item, cls=DecimalEncoder) + } + except Exception as e: + print(e) + return { + 'statusCode': 500, 'body': json.dumps({'message', 'Error.'}), + 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, + } find_handler = { "GET": { "/api/v1/healthz": healthzHandler, "/api/v1/create_user": createUserHandler, + "/api/v1/get_user": getUserHandler, + "/api/v1/delete_user": deleteUserHandler, + "/api/v1/update_user": updateUserHandler, } } From 5bad786f8515dac2c5c2df27aa36366da75233b4 Mon Sep 17 00:00:00 2001 From: jlevine18 Date: Fri, 16 Feb 2024 00:53:28 -0600 Subject: [PATCH 35/51] Update lambda.yml --- cloudformation/lambda.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 1ac4c5f..2a5e5c6 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -23,6 +23,11 @@ Parameters: AllowedPattern: ^[a-zA-Z0-9]+[a-zA-Z0-9-]+[a-zA-Z0-9]+$ Default: infra-admin-api-user-management-lambda + AdminAPIGWName: + Type: String + AllowedPattern: ^[a-zA-Z0-9]+[a-zA-Z0-9-]+[a-zA-Z0-9]+$ + Default: infra-admin-api-user-management-gw + Conditions: UseCustomDomainNameCond: !Equals [!Ref UseCustomDomainName, true] From a640d4298ed1dfa721ace5027252d288e22cc87c Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:13:37 -0600 Subject: [PATCH 36/51] Added log group --- cloudformation/lambda.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 2a5e5c6..5447aa0 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -118,6 +118,12 @@ Resources: - !GetAtt MyDynamoDBTable.Arn PolicyName: lambda-dynamo + AdminAPIUserManagementLambdaLogGroup: + Type: AWS::Logs::LogGroup + Properties: + LogGroupName: !Sub /aws/lambda/${LambdaFunctionName} + RetentionInDays: 7 + AdminAPIGateway: Type: AWS::Serverless::Api DependsOn: From 58778abcb73316a3bb6a5fa2b105a102bdff95ce Mon Sep 17 00:00:00 2001 From: kaushik327 Date: Thu, 22 Feb 2024 17:16:34 -0600 Subject: [PATCH 37/51] remove semicolons --- backend/user_funs.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/backend/user_funs.py b/backend/user_funs.py index 32fb822..25f740e 100644 --- a/backend/user_funs.py +++ b/backend/user_funs.py @@ -106,9 +106,9 @@ def default(self, obj): def createUserHandler(context, queryParams): try: - netid = queryParams["netid"]; - roleStr = queryParams["roleStr"]; - permStr = queryParams["permStr"]; + netid = queryParams["netid"] + roleStr = queryParams["roleStr"] + permStr = queryParams["permStr"] except: return { 'statusCode': 404, @@ -116,7 +116,7 @@ def createUserHandler(context, queryParams): 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'} } try: - create_user(netid, roleStr, permStr); + create_user(netid, roleStr, permStr) return { 'statusCode': 200, 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, @@ -131,7 +131,7 @@ def createUserHandler(context, queryParams): def getUserHandler(context, queryParams): try: - netid = queryParams["netid"]; + netid = queryParams["netid"] except: return { 'statusCode': 404, @@ -139,7 +139,7 @@ def getUserHandler(context, queryParams): 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'} } try: - get_user(netid); + get_user(netid) return { 'statusCode': 200, 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, @@ -154,7 +154,7 @@ def getUserHandler(context, queryParams): def deleteUserHandler(context, queryParams): try: - netid = queryParams["netid"]; + netid = queryParams["netid"] except: return { 'statusCode': 404, @@ -162,7 +162,7 @@ def deleteUserHandler(context, queryParams): 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'} } try: - delete_user(netid); + delete_user(netid) return { 'statusCode': 200, 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, @@ -177,9 +177,9 @@ def deleteUserHandler(context, queryParams): def updateUserHandler(context, queryParams): try: - netid = queryParams["netid"]; - newRoles = queryParams["newRoles"]; - newPerms = queryParams["newPerms"]; + netid = queryParams["netid"] + newRoles = queryParams["newRoles"] + newPerms = queryParams["newPerms"] except: return { 'statusCode': 404, @@ -187,7 +187,7 @@ def updateUserHandler(context, queryParams): 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'} } try: - update_user(netid, newRoles, newPerms); + update_user(netid, newRoles, newPerms) return { 'statusCode': 200, 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, From 7fe592f84b23a2a289430c22ebff05df1da26321 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:20:23 -0600 Subject: [PATCH 38/51] Update lambda.yml --- cloudformation/lambda.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 5447aa0..1a98525 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -121,7 +121,7 @@ Resources: AdminAPIUserManagementLambdaLogGroup: Type: AWS::Logs::LogGroup Properties: - LogGroupName: !Sub /aws/lambda/${LambdaFunctionName} + LogGroupName: !Sub /aws/lambda/${UserManagementLambdaName} RetentionInDays: 7 AdminAPIGateway: From 9d0cc77d2fc87835ecdc6b9e094a8e14e67c2803 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:26:16 -0600 Subject: [PATCH 39/51] Added item variable names and deleted main --- backend/user_funs.py | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/backend/user_funs.py b/backend/user_funs.py index 25f740e..ae80197 100644 --- a/backend/user_funs.py +++ b/backend/user_funs.py @@ -117,6 +117,7 @@ def createUserHandler(context, queryParams): } try: create_user(netid, roleStr, permStr) + item = get_user(netid) return { 'statusCode': 200, 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, @@ -139,7 +140,7 @@ def getUserHandler(context, queryParams): 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'} } try: - get_user(netid) + item = get_user(netid) return { 'statusCode': 200, 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, @@ -162,6 +163,7 @@ def deleteUserHandler(context, queryParams): 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'} } try: + item = get_user(netid) delete_user(netid) return { 'statusCode': 200, @@ -181,6 +183,7 @@ def updateUserHandler(context, queryParams): newRoles = queryParams["newRoles"] newPerms = queryParams["newPerms"] except: + item = get_user(netid) return { 'statusCode': 404, 'body': "No netid/roles/permissions provided", @@ -221,22 +224,3 @@ def lambda_handler(event, context): return execute(method, path, queryParams, event['requestContext']['authorizer']) except KeyError: return execute(method, path, queryParams, {}) - -if __name__ == "__main__": - netid = input("netid: ") - roles = input("roles: ") - perms = input("perms: ") - - create_user(netid, roles, perms) - - print(f"getting user: {get_user(netid)}") - - print(f"updating user: {update_user(netid, '11, 22', ' 22 , 11 ')}") - - print("deleting user") - - delete_user(netid) - - print(f"getting user: {get_user(netid)}") - - print(f"updating user: {update_user(netid, '11, 22', ' 22 , 11 ')}") From aeb44ade762d877c586b734fd9c50a042e30000a Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:29:04 -0600 Subject: [PATCH 40/51] Update user_funs.py --- backend/user_funs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/user_funs.py b/backend/user_funs.py index ae80197..63d1231 100644 --- a/backend/user_funs.py +++ b/backend/user_funs.py @@ -183,7 +183,6 @@ def updateUserHandler(context, queryParams): newRoles = queryParams["newRoles"] newPerms = queryParams["newPerms"] except: - item = get_user(netid) return { 'statusCode': 404, 'body': "No netid/roles/permissions provided", @@ -191,6 +190,7 @@ def updateUserHandler(context, queryParams): } try: update_user(netid, newRoles, newPerms) + item = get_user(netid) return { 'statusCode': 200, 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, From b11b9de587475149253283029fa52f9659218b4e Mon Sep 17 00:00:00 2001 From: PranjalChaitanya <44535826+PranjalChaitanya@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:36:34 -0600 Subject: [PATCH 41/51] Update lambda.yml --- cloudformation/lambda.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 1a98525..5308f04 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -81,6 +81,14 @@ Resources: Dimensions: - Name: 'FunctionName' Value: !Ref AdminAPIUserManagementLambda + + LambdaFunctionPermission: + Type: "AWS::Lambda::Permission" + Properties: + Action: "lambda:InvokeFunction" + Principal: apigateway.amazonaws.com + FunctionName: !Ref MyLambdaFunction + DependsOn: MyWebSocket AdminAPIUserManagementLambdaIAMRole: Type: AWS::IAM::Role From 65333e8f6eee977c0d9977723fb9694eb4e9b4b0 Mon Sep 17 00:00:00 2001 From: PranjalChaitanya <44535826+PranjalChaitanya@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:41:11 -0600 Subject: [PATCH 42/51] Update lambda.yml --- cloudformation/lambda.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 5308f04..41bfd71 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -87,8 +87,8 @@ Resources: Properties: Action: "lambda:InvokeFunction" Principal: apigateway.amazonaws.com - FunctionName: !Ref MyLambdaFunction - DependsOn: MyWebSocket + FunctionName: !Ref AdminAPIUserManagementLambda + DependsOn: AdminAPIGWName AdminAPIUserManagementLambdaIAMRole: Type: AWS::IAM::Role From 0b37669dfdeaf384df649f8f19b8e028c5f33891 Mon Sep 17 00:00:00 2001 From: PranjalChaitanya <44535826+PranjalChaitanya@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:43:31 -0600 Subject: [PATCH 43/51] Update lambda.yml --- cloudformation/lambda.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 41bfd71..9a6580b 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -88,7 +88,7 @@ Resources: Action: "lambda:InvokeFunction" Principal: apigateway.amazonaws.com FunctionName: !Ref AdminAPIUserManagementLambda - DependsOn: AdminAPIGWName + DependsOn: AdminAPIGateway AdminAPIUserManagementLambdaIAMRole: Type: AWS::IAM::Role From 58fb76a20e058eb7bc475c71f3b6ba4afc4e3d88 Mon Sep 17 00:00:00 2001 From: PranjalChaitanya <44535826+PranjalChaitanya@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:55:34 -0600 Subject: [PATCH 44/51] Update lambda.yml --- cloudformation/lambda.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index 9a6580b..b961475 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -121,6 +121,8 @@ Resources: - dynamodb:GetItem - dynamodb:Scan - dynamodb:UpdateItem + - dynamodb: DeleteItem + - dynamodb: PutItem Effect: Allow Resource: - !GetAtt MyDynamoDBTable.Arn From d84153258e7e3008c041632a099b5bb22c70f149 Mon Sep 17 00:00:00 2001 From: kaushik327 Date: Thu, 22 Feb 2024 17:55:51 -0600 Subject: [PATCH 45/51] fix: correctly format error message --- backend/user_funs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/user_funs.py b/backend/user_funs.py index 63d1231..221c4bb 100644 --- a/backend/user_funs.py +++ b/backend/user_funs.py @@ -126,7 +126,7 @@ def createUserHandler(context, queryParams): except Exception as e: print(e) return { - 'statusCode': 500, 'body': json.dumps({'message', 'Error.'}), + 'statusCode': 500, 'body': json.dumps({'message': 'Error.'}), 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, } @@ -149,7 +149,7 @@ def getUserHandler(context, queryParams): except Exception as e: print(e) return { - 'statusCode': 500, 'body': json.dumps({'message', 'Error.'}), + 'statusCode': 500, 'body': json.dumps({'message': 'Error.'}), 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, } @@ -173,7 +173,7 @@ def deleteUserHandler(context, queryParams): except Exception as e: print(e) return { - 'statusCode': 500, 'body': json.dumps({'message', 'Error.'}), + 'statusCode': 500, 'body': json.dumps({'message': 'Error.'}), 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, } @@ -199,7 +199,7 @@ def updateUserHandler(context, queryParams): except Exception as e: print(e) return { - 'statusCode': 500, 'body': json.dumps({'message', 'Error.'}), + 'statusCode': 500, 'body': json.dumps({'message': 'Error.'}), 'headers': {'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*'}, } From a35e10337f9e3f760a69d7808762e2b3e08875b3 Mon Sep 17 00:00:00 2001 From: PranjalChaitanya <44535826+PranjalChaitanya@users.noreply.github.com> Date: Thu, 22 Feb 2024 17:59:16 -0600 Subject: [PATCH 46/51] Update lambda.yml --- cloudformation/lambda.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index b961475..dd1d5aa 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -121,8 +121,8 @@ Resources: - dynamodb:GetItem - dynamodb:Scan - dynamodb:UpdateItem - - dynamodb: DeleteItem - - dynamodb: PutItem + - dynamodb:DeleteItem + - dynamodb:PutItem Effect: Allow Resource: - !GetAtt MyDynamoDBTable.Arn From b9c1a2bd3b0cef485483cec5b421134fc0b6c939 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 29 Feb 2024 17:14:36 -0600 Subject: [PATCH 47/51] Changed HTTPS methods for lambda functions --- backend/user_funs.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/user_funs.py b/backend/user_funs.py index 221c4bb..e8769a4 100644 --- a/backend/user_funs.py +++ b/backend/user_funs.py @@ -206,11 +206,15 @@ def updateUserHandler(context, queryParams): find_handler = { "GET": { "/api/v1/healthz": healthzHandler, - "/api/v1/create_user": createUserHandler, "/api/v1/get_user": getUserHandler, - "/api/v1/delete_user": deleteUserHandler, + } + "PUT": { + "/api/v1/create_user": createUserHandler, "/api/v1/update_user": updateUserHandler, } + "DELETE": { + "/api/v1/delete_user": deleteUserHandler, + } } def lambda_handler(event, context): From a5b6e03f248b94f66a7b906b3ea84db9ec3b98d7 Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 29 Feb 2024 17:18:08 -0600 Subject: [PATCH 48/51] Changed HTTPS Methods --- docs/swagger.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/swagger.yml b/docs/swagger.yml index 3b0441d..95a629e 100644 --- a/docs/swagger.yml +++ b/docs/swagger.yml @@ -29,7 +29,7 @@ paths: uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations /api/v1/create_user: - get: + put: summary: Creates a user operationId: createUser parameters: @@ -93,7 +93,7 @@ paths: uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations /api/v1/delete_user: - get: + delete: summary: Deletes a User operationId: deleteUser parameters: @@ -119,7 +119,7 @@ paths: uri: Fn::Sub: arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AdminAPIUserManagementLambda}/invocations /api/v1/update_user: - get: + put: summary: updates existing user operationId: updateUser parameters: From 51c26c631abace1db5349b0f38c51ec17f3d9cbc Mon Sep 17 00:00:00 2001 From: adarshk-5 <148798808+adarshk-5@users.noreply.github.com> Date: Thu, 29 Feb 2024 17:18:47 -0600 Subject: [PATCH 49/51] Update user_funs.py --- backend/user_funs.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/user_funs.py b/backend/user_funs.py index e8769a4..02abeb9 100644 --- a/backend/user_funs.py +++ b/backend/user_funs.py @@ -207,11 +207,11 @@ def updateUserHandler(context, queryParams): "GET": { "/api/v1/healthz": healthzHandler, "/api/v1/get_user": getUserHandler, - } + }, "PUT": { "/api/v1/create_user": createUserHandler, "/api/v1/update_user": updateUserHandler, - } + }, "DELETE": { "/api/v1/delete_user": deleteUserHandler, } From 4c528d283ca179d4e8b8e3f50a8b65b9a9072ab3 Mon Sep 17 00:00:00 2001 From: PranjalChaitanya <44535826+PranjalChaitanya@users.noreply.github.com> Date: Thu, 7 Mar 2024 17:11:12 -0600 Subject: [PATCH 50/51] Update lambda.yml --- cloudformation/lambda.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cloudformation/lambda.yml b/cloudformation/lambda.yml index dd1d5aa..fb69c3b 100644 --- a/cloudformation/lambda.yml +++ b/cloudformation/lambda.yml @@ -142,6 +142,10 @@ Resources: Name: !Ref AdminAPIGWName Description: Admin API Gateway AlwaysDeploy: True + Cors: + AllowHeaders: "'*'" + AllowMethods: "'*'" + AllowOrigin: "'*'" DefinitionBody: Fn::Transform: Name: AWS::Include From 3cd52e216978751a21850d7c2f84e5130efea160 Mon Sep 17 00:00:00 2001 From: kaushik327 Date: Thu, 7 Mar 2024 17:30:37 -0600 Subject: [PATCH 51/51] ds store --- .DS_Store | Bin 8196 -> 10244 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.DS_Store b/.DS_Store index 8ad8fca0587a02012438fe8948965c24dbf81563..0ba6da0ab96c21db9ceed80db78165964d8e56fe 100644 GIT binary patch delta 598 zcmZp1XbF&DU|?W$DortDU{C-uIe-{M3-C-V6q~50$SA)tU^hRb{AL~j7RLIVbi?4} z{M-Vd0tN;a!?_@mL60GwA(NpbH{Zo2DJMS(D8}(Teu;Qg?@>oo`4qhJ1sOAAJwi&10h1kt zgf|}&n!zZ5>uHMv`afAS|W z+099!3XGFii}5i@t(*K_Olk66F)lV|b+D@x#g!)Wi}N7328;%i9Yqx<7mH8X*wD^C zu|ZCd8RU0hG;jk6S5Q=JEd0(qnO`PQgb5Ns8X###1_lEVJ-I-pS2mBKgdvq7k0E8? HySjFUfLJBY@i?9+%cC(f63`UNW;^ds9{QR8B6GbiR*%^`;5*d;i zvKdkt@)%NJa*RNm(4=zG4TF>Oa|?hnFo32aH{Zo2DJMS(D9y37^`KTn?@>n}8$(qJ zLX|pBWd#|?)=d&q+WbsZ0m<=&St$7*ub5mTt~5DIoQDn0H2^A{ ud`^6dATz}A65K%A6%?Es3%@f@=2r>i0Qwme$PAO?d8Rt!b2OdZJP`ncvxMjX