且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用IAM身份验证的AppSync中的组授权

更新时间:2023-12-02 21:00:22

今天,我正在使用与您的要求类似的东西。为此,我使用来自Cognito用户池的JWT令牌在放大请求中添加了自定义标头。就我而言,我在Lambda解析器中解析了JWT。对于您的情况,您需要在前端解析JWT令牌,然后在自定义标头中将其解析(并编码)发送。在解析器内部,您可以解码标题值并从声明中提取组。

Today i'm using something similar to your requirement. For that I add a custom header in the amplify request with the JWT token from Cognito User Pool. In my case, I parse the JWT inside a lambda resolver. For your case, you'll need to parse the JWT token in the frontend and send it parsed (and encoded) in the custom header. Inside your resolver you can decode the header value and extract the groups from the claims.