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

profile picture
질문됨 10달 전242회 조회
1개 답변
2
수락된 답변

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
전문가
답변함 10달 전
profile pictureAWS
전문가
검토됨 10달 전
  • 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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠