On Amplify's GraphQL, can we check the authentication or permission of updating contents before call the GraphQL API from browser?

0

I'm creating a corporate in-house information management app as web apps with Amplify and Amplify-Studio. Users on the app will be managed by Cognito via Amplify-Studio's user management screen.

I want to implement a function to restrict users to update records on specific types like Role Based Access Control.

I'm planning to use @auth directive with groups restriction.

On the update form page on the app, I also want to tell users having no updating permission to having no permission to avoid bad experiences like users noticing having no permission after input a lot of information for form on the update form page.

So I want to know how to get the users permission on GraphQL API from browser side.

1 個回答
1

Hello,

From Amplify/App sync perspective, there is no built-in way to retrieve the permissions of a user before hitting the App sync GraphQL endpoint.

One possible way I could think of is Cognito Pools would return groups of the User(in the JWT token) when a user logs in and you can get the groups and use it directly in your Front end code. This can be achieved like this: accessToken.payload['cognito:groups']

References


[+] https://github.com/aws-amplify/amplify-flutter/issues/413

[+] https://github.com/aws-amplify/amplify-android/issues/1655

I hope this answers your query.

AWS
支援工程師
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南