I have a question about the integration of Cognito and API Gateway and I hope that you can help me with that. I am thinking of making an application in which I would like the authentication process with third parties (Facebook, Twitter …), so I discard Cognito User Pool, then I have Cognito Identity Pool, but this is where my doubts grow.
- How can I integrate it with API Gateway?
- Should I use API Gateway Custom Authorizer to manage the token generated by Cognito?
- If I do not use the Custom Authorizer, How can I restrict access to the API Methods based on the user profile (admin, client …)?
Thanks for your help
2
Answers
How can I integrate it with API Gateway?
Should I use API Gateway Custom Authorizer to manage the token generated by Cognito?
If I do not use the Custom Authorizer, How can I restrict access to the API Methods based on the user profile (admin, client …)?
Edit: maybe this will help http://www.slideshare.net/AmazonWebServices/securing-serverless-workloads-with-cognito-and-api-gateway-part-i-aws-security-day
You can use the aws-sdk to generate a signed request to API Gateway if authorizer is set as AWS_IAM. First get some temporary credentials, then create a signed request.
Get Credentials (example with javascript sdk ) :
This example is not perfect but it is a good starting point on signed request in AWS.
Of course, don’t forget to give proper permissions to your authenticated identities so that they can invoke the API.