2017-05-16 4 views
2

Meine Benutzer Anmeldung mit Facebook und Tabelle hat grundlegende Benutzerinformationen. Ich möchte, dass Benutzer nur ihre eigenen Datensätze zu aktualisieren, zu löschen, etc. aber auch haben Lesezugriff auf Attribute aller anderen Benutzer. Z.B. Sieh ihre Namen. Wie erstelle ich eine Richtlinie, die dies erlaubt? Dies ist für das Szenario nicht 1:Feinkörniger Zugang in DynamoDb

{ 
"Version": "2012-10-17", 
"Statement": [ 
    { 
     "Sid": "FullAccessToUserItems", 
     "Effect": "Allow", 
     "Action": [ 
      "dynamodb:GetItem", 
      "dynamodb:BatchGetItem", 
      "dynamodb:Query", 
      "dynamodb:PutItem", 
      "dynamodb:UpdateItem", 
      "dynamodb:DeleteItem", 
      "dynamodb:BatchWriteItem" 
     ], 
     "Resource": [ 
      "arn:aws:dynamodb:us-west-2:123456789012:table/Users" 
     ], 
     "Condition": { 
      "ForAllValues:StringEquals": { 
       "dynamodb:LeadingKeys": [ 
         "${graph.facebook.com:id}" 
       ] 
      } 
     } 
    } 
] 

}

Antwort

1

einfach ein weiteres Statement mit Leseberechtigungen für ganzen Tisch.

So etwas sollte funktionieren:

{ 
    "Sid": "ReadAccess", 
    "Effect": "Allow", 
    "Action": [ 
     "dynamodb:GetItem", 
     "dynamodb:BatchGetItem", 
     "dynamodb:Query" 
    ], 
    "Resource": [ 
     "arn:aws:dynamodb:us-west-2:123456789012:table/Users" 
    ] 
} 

Und die ganze Politik so sein würde. Beachten Sie die zweite Aussage unten:

{ 
"Version": "2012-10-17", 
"Statement": [ 
    { 
     "Sid": "FullAccessToUserItems", 
     "Effect": "Allow", 
     "Action": [ 
      "dynamodb:GetItem", 
      "dynamodb:BatchGetItem", 
      "dynamodb:Query", 
      "dynamodb:PutItem", 
      "dynamodb:UpdateItem", 
      "dynamodb:DeleteItem", 
      "dynamodb:BatchWriteItem" 
     ], 
     "Resource": [ 
      "arn:aws:dynamodb:us-west-2:123456789012:table/Users" 
     ], 
     "Condition": { 
      "ForAllValues:StringEquals": { 
       "dynamodb:LeadingKeys": [ 
         "${graph.facebook.com:id}" 
       ] 
      } 
     } 
    }, 
    { 
     "Sid": "ReadAccess", 
     "Effect": "Allow", 
     "Action": [ 
      "dynamodb:GetItem", 
      "dynamodb:BatchGetItem", 
      "dynamodb:Query" 
     ], 
     "Resource": [ 
      "arn:aws:dynamodb:us-west-2:123456789012:table/Users" 
     ] 
    } 
] 
}