- Newest
- Most votes
- Most comments
You're correct that Amazon Verified Permissions (AVP) currently doesn't support the "is" operator in the Cedar policy language, as it's using an earlier version of Cedar. However, there are alternative approaches you can use to achieve the same result.
The solution you mentioned, adding a "type" attribute to your schemas, is actually a common and recommended approach. While it may seem less elegant than using the "is" operator, it's a practical and effective method. Here's how you could implement it:
- In your schema, add a "type" attribute to your resource definitions. For example:
{ "documentale_cosmogas::document": { "type": "String", "attributes": { "type": { "type": "String" } } } }
- When creating resources, set the "type" attribute to the resource type:
{ "uid": "documentale_cosmogas::document:123", "type": "documentale_cosmogas::document" }
- Then, your policy would look like this:
permit(principal, action, resource)
when { resource.type == "documentale_cosmogas::document" };
This approach allows you to achieve the same functionality as the "is" operator while remaining compatible with the version of Cedar supported by AVP.
Another alternative, if applicable to your use case, is to use the namespace of the resource UID. AVP allows you to check the namespace of a resource using the has_prefix() function. For example:
permit(principal, action, resource)
when { has_prefix(resource.id, "documentale_cosmogas::document:") };
This method works if your resource UIDs consistently follow a pattern where the type is included in the prefix.
Both of these approaches provide ways to check the type of a resource in your policies, allowing you to implement the functionality you need within the constraints of the current AVP Cedar version.
Sources
Fine-Grained Authorization – Amazon Verified Permissions FAQs – AWS
Fine-Grained Authorization – Amazon Verified Permissions Features – AWS
Relevant content
asked 2 years ago
asked 2 years ago
