且构网

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

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

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

今天我正在使用与您的要求相似的东西.为此,我在放大请求中添加了一个自定义标头,其中包含来自 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.