Control access for invoking Rest API in API Gateway

0

I have several API gateway resources which I want to allow other services to invoke them.
Say I have these two endpoints:
/tasks
/setting
My clients are some services, they invoke these Rest APIs like the following request: (It is written in Javascript, but they can use any other programming languages, but can't use AWS SDK)
fetch('.../tasks')
.then((tasks) => {
console.log('Tasks:', tasks)
});
I need to check client's permissions as they're calling my API. When a service send a request to /tasks, I should check its permission and see if it doesn't have the required permission, I will return 403 as response.
I want to know what it the best approach to implement it? Should I use AWS Cognito User pool integrated with Identity pool or a Custom authorizer?
If my question is not clear as enough, please comment it, I'll give more information.
I hope someone has related experiences and could help me.

Edited by: Farzan on Jan 25, 2020 4:10 AM

Edited by: Farzan on Jan 25, 2020 4:25 AM

Farzan
질문됨 4년 전352회 조회
4개 답변
0
수락된 답변

When you define app client settings in your pool you can define which scopes the client will be allowed. The scopes you defined for your resources should appear under "Allowed Custom Scopes". In that case the clients will have not access to more scopes than what you defined. They could ask for it, but they will not get it.
There is also this article published in knowledge center that explains the process better end-to-end https://aws.amazon.com/premiumsupport/knowledge-center/cognito-custom-scopes-api-gateway/

anzap
답변함 4년 전
profile picture
전문가
검토됨 한 달 전
0

Hi Farzan,

You could do what you want using Cognito user pools by defining app clients, Resource servers and scopes. You can then secure your apis in AWS API Gateway using CognitoUserPoolAuthorizer and previously defined scopes on resource methods.

Check https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-define-resource-servers.html and https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-enable-cognito-user-pool.html

anzap
답변함 4년 전
profile picture
전문가
검토됨 한 달 전
0

Thanks for your help.
But I think in that case my clients can ask for any scopes they want and I'm not able to control whether the requested scopes are accessible for them or not.

Farzan
답변함 4년 전
0

I haven't known about this feature. Thanks a lot for your help.
Very useful..

Farzan
답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인