Skip to content

Amazon Verified Permissions "is" operator alternative

0

I am trying to implement a very simple policy on AVP where the "when" clause checks on the resource type. Policy example:

permit(principal, action, resource) when { resource is namespace::document };

Now, as I understood AVP does not support "is" operator because it's in a non-supported Cedar version and AVP support only the 2.4 and below, so I am trying to understand what alternatives I have. The only solution I thought is to add a "type" attribute to each schemas but honestly I hope someone can help me to find a more decent solution.

Thanks, Lorenzo C.

asked 2 years ago344 views

1 Answer
0
Accepted Answer

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:

  1. In your schema, add a "type" attribute to your resource definitions. For example:
{
  "documentale_cosmogas::document": {
    "type": "String",
    "attributes": {
      "type": { "type": "String" }
    }
  }
}
  1. When creating resources, set the "type" attribute to the resource type:
{
  "uid": "documentale_cosmogas::document:123",
  "type": "documentale_cosmogas::document"
}
  1. 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

answered 2 years ago

EXPERT

reviewed 2 years ago

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.