Cedalio
Search
K

Access Policies

Database permissions for a single address.
For a detailed explanation on Access Policies check our Technology section.

setAccessPolicies

Sets Access Policies for any number of addresses.
There's no need to send all the existing policies alongside the ones you want to create/change. Policies not sent in this method's payload will be kept unchanged. Policies sent in this method will override existing policies. In case you want to remove a Policy, see resetAccessPolicyForUser.
An address can only have one Access Policy. This method will return an error if you try to set two Policies for the same address.

Parameters

  • deploymentId (string): ID of a deployment.
  • policies (SetAccessPolicy[]): The policies you want to set.

Example

Schema
Request
Response
Error
type Post @model {
title: String!
description: String
}
const response = await cedalioSdk.setAccessPolicies({
deploymentId: 'Your deployment id',
policies: [
{
address: 'Address 1',
policyType: 'ALLOW_FULL_ACCESS'
},
{
address: 'Address 2',
policyType: 'FIELD_BASED',
accessRules: [
{
objectTypeName: 'Post',
fields: [
{
fieldName: 'title',
write: false,
read: true
}
]
}
]
}
]
});
{
ok: true,
status: 201,
data: {}
}
{
ok: false,
status: 401,
error: {
message: 'The server error',
payload: { /* Payload */ }
}
}

setAccessPolicy

Sets a policy for a single address in a database.
An address can only have one Access Policy. This method will return an error if you try to create two Policies for the same address.

Parameters

  • deploymentId (string): ID of a deployment.
  • policy (SetAccessPolicy): The policy you want to set.

Example

Schema
Request
Response
Error
type Post @model {
title: String!
description: String
}
const response = await cedalioSdk.setAccessPolicy({
deploymentId: 'Your deployment id',
policy: {
address: 'Address 1',
policyType: 'ALLOW_FULL_ACCESS'
}
});
{
ok: true,
status: 201,
data: {}
}
{
ok: false,
status: 401,
error: {
message: 'The server error',
payload: { /* Payload */ }
}
}

getAccessPolicyForUser

Gets the Access Policy for an address in a database.

Parameters

  • deploymentId (string): ID of a deployment.
  • address (string): The user's address

Example

Schema
Request
Response
Error
type Post @model {
title: String!
description: String
creator: User!
}
type User @model {
name: String!
address: String
posts: [Post]!
}
const response = await cedalioSdk.getAccessPolicyForUser({
deploymentId: 'deployment id',
address: 'Address 1'
});
{
ok: true,
status: 200,
data: [
{
policyType: 'ALLOW_FULL_ACCESS',
accessRules: [
{
objectTypeName: 'Post',
fields: [
{
fieldName: 'title',
write: true,
read: true
}
]
},
{
objectTypeName: 'Post',
fields: [
{
fieldName: 'description',
write: true,
read: true
}
]
}
]
},
{
policyType: 'FIELD_BASED',
accessRules: [
{
objectTypeName: 'User',
fields: [
{
fieldName: 'name',
write: false,
read: true
}
]
}
]
}
]
}
{
ok: false,
status: 401,
error: {
message: 'The server error',
payload: { /* Payload */ }
}
}

resetAccessPolicyForUser

Resets the user's Access Policy to the defaults for an address in a database.

Parameters

  • deploymentId (string): ID of a deployment.
  • address (string): The user's address

Example

Request
Response
Error
const response = await cedalioSdk.resetAccessPolicyForUser({
deploymentId: 'deployment id',
address: 'Address 1'
});
{
ok: true,
status: 200,
data: {}
}
{
ok: false,
status: 401,
error: {
message: 'The server error',
payload: { /* Payload */ }
}
}