Fine-grained Data Permissions
Vendia Share has controls to allow data producers to limit the actions of data consumers on stored data.
Vendia’s fine-grained data permissions are designed to be both simple to use and highly flexible. This feature enables administrators to easily limit who can take action on data written to a Uni.
NOTE: Defining fine-grained permissions on data is optional. Not including the Access Control List (ACL) will result in the default behavior of giving full Create, Read, Update and Delete (CRUD) access to all Node partners in the Uni network. This default behavior can be overridden by applying a Sharing Policy.
Scope of Fine-grained Data Permissions
Fine-grained data permissions serve to constrain the visibility of data in a Uni. They also set boundaries on the the ability to modify data in a Uni. It does not affect how users interact with Vendia APIs. If you’re interested in defining how to control how Vendia Share users create and manage Unis, please refer to Role-based Access Controls.
Key Terms
-
ACL: Access Control List (ACL) is a list of objects that contain the fine-grained definitions that control access to data in a Uni.
-
Principal: Principal is a list of nodes to which the ACL is applied.
-
Path: [Optional] The path defines the attribute of the object to apply the ACL operations. This field is optional. If it is not specified, the specified operations are applied to the entire object.
-
Operations: Operations define what action a Principal can take on data.
-
aclInput: aclInput is a GraphQL object that contains a list of Access Control List (ACL) definitions that are applied when data is added or updated in a Uni.
Operations
Vendia Share allows the following operations to be assigned to Principals when data is added or updated in a Uni:
READ
: Permits the Principal to list and get data.WRITE
: Permits the Principal to update, put, and delete data.ALL
: Permits the Principal to bothREAD
andWRITE
data.UPDATE_ACL
: Permits the Principal to update the ACL. This permission can only be granted by the Principal who added the data.
NOTE: The ALL
operation does not include UPDATE_ACL
.
Schema Definition Requirement
In order to take advantage of fine-grained data permissions, the JSON schema must include the x-vendia-acls
top-level type. For example, if my JSON schema as two distinct types - Foo
and Bar
- and I wish to enable fine-grained permissions on each type, I would set x-vendia-acls
as the following:
NOTE: The x-vendia-acls
top-level type must be defined when the Uni is created. Schemas cannot be updated to include this definition after the Uni has been created.
Restricting Data Access
When creating data on the Vendia Share platform, data producers can optionally restrict access to Node partners in the Network. The restriction can be either global (across all fields), or fine-grained (different for each field).
Sharing Policies
Instead of relying on data producers to set the appropriate ACL on every item entry, each Node partner can configure sharing policies. Sharing policies are ACLs that are globally defined. If an item is created without an explicit ACL, the matching sharing policy for the entity will be used.
Creating a Sharing Policy
In the Vendia Share UI, sharing policies can be configured in the Node Settings. After configuration, newly created items can begin to utilize the policy configuration. Sharing policies are also available to be created through the GraphQL API, CLI, and SDK.
Using a Sharing Policy
When configured, sharing policies are used without any additional configuration for API requests. A sharing policy’s configuration will be used has the default ACL when an explicit ACL is not defined in the GraphQL mutation.
GraphQL Request
Response
Advanced
API Usage Examples
Now that we have a sense of the operations that can be allowed, how to define our list of principals, and the how to specify that our JSON schema types will use fine-grained permissions, let’s go through a very simple example to illustrate how to assign controls when adding or updating data in a Uni.
We will provide an example to demonstrate how nodes can share recipe information in a controlled manner in a Uni. We will also demonstrate how to query data that has controls associated with it.
Data Model and Uni Configuration
Below is the JSON schema that will be used as the basis for our queries.
Click to view Recipe Schema
Click to view sample Recipe node configuration
Note: This example uses a 3-node Uni configuration, which is not viable for Starter tier users given the node limits enforced. See full details on the Pricing page. Starter tier users can still follow this example by omitting one of the nodes in the configuration shown below.
Our Uni is made of 3 nodes - Alice
, Bob
, and Eve
. All queries will make references to these node names.
NOTE: Be sure to update the userId
and region
appropriately if you are deploying the example.
Writing Data with Fine-grained Control
The following mutations should be run from the Alice
node.
Sample Mutation - Allow Read-Only Access to a Recipe
In this example, we will specify that all nodes in a Uni will have the ability to READ
all attributes of our Red Velvet Cake
recipe. However, only the node Alice
will have the ability to WRITE
changes.
This mutation adds our aclInput
in addition to our standard input
.
Sample Mutation - Allow Different Operators By Node
In this mutation, we will specify that the Bob
node has the ability to view all attributes of our Sprinkles Cupcake
recipe. Eve
will only be able to read the name
, price
, recipeType
, and recipeYield
. The attributes ingredients
and directions
will not be visible in query results from Eve
.
This mutation adds our aclInput
in addition to our standard input
.
In the example above, all nodes have the ability to read the name and sku, while only NodeOne has the ability to read the price and recipe information.
Reading Data with Fine-grained Control
Let’s go ahead and issue queries from our nodes and see how the results change depending upon the node from which the query was issued.
Sample Query - Read data that may or may not be shared
Alice
Since Alice
added the recipes, the node is the owner of the two Recipes
. The query will return all attributes of each Recipe
.
Sample Query Result - Alice Results
NOTE: The _id
of each Recipe
will be different in your results.
Bob Results
Bob
has been granted READ
access to all attributes of both Recipes
- implicitly for Red Velvet Cake
and explicitly for Sprinkles Cupcake
. The results of our query will match the results of Alice
.
Sample Query Result - Bob Results
NOTE: The _id
of each Recipe
will be different in your results.
Eve Results
Eve
has been granted READ
access to all attributes of Red Velvet Cake
but can only view a subset of Sprinkles Cupcake
attributes. Eve
cannot view the data for sku
, ingredients
, or directions
.
Sample Query Result - Eve Results
NOTE: The _id
of each Recipe
will be different in your results.
Updating Data with Fine-grained Control
Since Alice
created both Recipe
records, Alice
has full access and can run a updateRecipe
mutation to update any of the attributes of both records.
Since neither Bob
nor Eve
have the ability to write data for either record, both will receive an Unauthorized
exception when running the updateRecipe
mutation.
Sample mutation - updating data without access
NOTE: The _id
you use will be different in your Uni.
Sample Mutation Result - Bob Results
Sample Mutation Result - Eve Results
Effects of Fine-grained Controls on Blocks
Vendia Share will take fine-grained permissions into account when writing transactions into a block. The block record for each node will reflect the operations permitted.
If a node has permission to the data then it will be visible in the transactions
. The list of mutations
will contain clear transparency regarding what was changed in the Uni. The redactedTxHash
value will be null. If, however, a node does not have full visibility into the data that is part of the block then it will be reflected. The mutations
will only display the subset of data to which the node should have access. The redactedTxHash
will not be null.
For example, if the following list_Blocks
query is run from Eve
, we will only see the transaction data that should be visible.
Eve Results
The Mutations
for the addition of the Sprinkles Cupcake
only includes data Eve
has access to.