CEDAR Schema Entity attribute of type Entity - Error in testing policy

1

Iam just starting with Amazon Verified Permissions and doing some exercies. I created a schema for a Post entity with an attribute of type Entity referencing a User entity. I had to use the JSON editor as the visual editor does not support this type. Here is my schema

{
    "SampleForum": {
        "actions": {
            "Create": {
                "appliesTo": {
                    "principalTypes": [
                        "User"
                    ],
                    "resourceTypes": [
                        "Post"
                    ]
                }
            },
            "Edit": {
                "appliesTo": {
                    "principalTypes": [
                        "User"
                    ],
                    "resourceTypes": [
                        "Post"
                    ]
                }
            },
            "Delete": {
                "appliesTo": {
                    "resourceTypes": [
                        "Post"
                    ],
                    "principalTypes": [
                        "User"
                    ]
                }
            }
        },
        "entityTypes": {
            "Post": {
                "shape": {
                    "type": "Record",
                    "attributes": {
                        "State": {
                            "type": "String",
                            "required": true
                        },
                        "Author": {
                            "name": "User",
                            "required": true,
                            "type": "Entity"
                        }
                    }
                },
                "memberOfTypes": []
            },
            "User": {
                "memberOfTypes": [],
                "shape": {
                    "attributes": {},
                    "type": "Record"
                }
            }
        }
    }
}

When iam now testing my policies in Test Bench i receive an error message telling me that the User entity is missing an id attribute.

Enter image description here

Anyone can give me a clue on what iam doing wrong? Thank you, Stefan

1 Answer
2
Accepted Answer

Hi Stefan, I believe that your user is improperly defined: id is required for a user entity (in fact for any entity See https://docs.cedarpolicy.com/syntax-entity.html#overview-of-entities for some examples. Best, Didier

profile pictureAWS
EXPERT
answered 9 months ago
profile pictureAWS
EXPERT
reviewed 9 months ago
  • Oh my bad. Actually my user was properly defined, but my policy was wrong. I had an attribute id before and matched the author with principal.id. I missed to changed the policy after i changed the schema. Nevertheless you answer led me into the right direction. Thanks.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions