1 Answer
- Newest
- Most votes
- Most comments
0
You can Restrict API Gateway Access Based on Cognito Custom Attributes (like "Tenant"), you can implement the following approach:
-
Use API Gateway with Cognito Authorizer: Ensure that your API Gateway uses a Cognito User Pool authorizer to authenticate and authorize requests.
-
Pass Cognito User Attributes to Lambda: Extract custom attributes (like "Tenant") in your Lambda function from the JWT token provided by Cognito.
-
Implement Authorization Logic in Lambda: Use the extracted custom attribute to control access to DynamoDB tables within your Lambda function.
answered 2 years ago

Thanks for your answer Basel. I have the idea of implementing the auth logic myself using the custom attribute as a backup; I was kind of hoping that wouldn't be the answer as utilising AWS' native IAM policies would be ideal from a security standpoint I imagine. Is there no way to get the Lambda (when called by a cognito user via API Gateway's cognito authorizer) to retain the Principal Tags from the calling user? Then at the very least I can write a role based policy and control what the Lambda has access to using the attributes of the calling user.