小编Mik*_*löf的帖子

96
推荐指数
6
解决办法
7万
查看次数

使用IAM身份验证在AppSync中进行组授权

我的服务需要用户组来授权访问数据.

AppSync文档中的组授权示例基于用户池声明.我正在使用IAM身份验证,因此$ context.identity不包含声明或任何类似信息.

例如,请参阅以下网址中的 "用例:组可以创建新记录"主题:https: //docs.aws.amazon.com/appsync/latest/devguide/security-authorization-use-cases.html

#set($expression = "")
#set($expressionValues = {})
#foreach($group in $context.identity.claims.get("cognito:groups"))
    #set( $expression = "${expression} contains(groupsCanAccess, :var$foreach.count )" )
    #set( $val = {})
    #set( $test = $val.put("S", $group))
    #set( $values = $expressionValues.put(":var$foreach.count", $val))
    #if ( $foreach.hasNext )
    #set( $expression = "${expression} OR" )
    #end
#end
{
    "version" : "2017-02-28",
    "operation" : "PutItem",
    "key" : {
        ## If your table's hash key is not named 'id', update it here. **
        "id" : { "S" …
Run Code Online (Sandbox Code Playgroud)

amazon-dynamodb aws-appsync

6
推荐指数
1
解决办法
598
查看次数