Skip to content

Component Policies

Policies provide a declarative way to enforce security and access control rules on your components. Instead of writing custom logic for every access control scenario, you define policies that the platform automatically evaluates and enforces.


Overview

Each component can have one or more policies configured in its settings. Policies are evaluated based on their type and priority, and they control who can access specific fields or data within the component.

Key characteristics:

  • Policies are defined per component version
  • Multiple policies can coexist; a field is allowed when any enabled policy grants it (see How it works)
  • Policies can be enabled or disabled without removing them
  • Owners and Maintainers bypass all policy checks

Policy Structure

A policy is defined with the following properties:

Property Type Required Description
type string Yes The policy type. Currently supported: field_access
name string Yes Human-readable name for the policy
description string No Optional explanation of what the policy does
enabled boolean Yes Whether the policy is currently active
priority number No Evaluation order, highest first (default: 0). It does not change the outcome: there are no deny rules
config object Yes Type-specific configuration object

Example

{
  "type": "field_access",
  "name": "Restrict Salary Field",
  "description": "Only HR managers can read or update the salary field",
  "enabled": true,
  "priority": 10,
  "config": {
    "fields": ["salary", "bonus"],
    "actions": ["read", "update"],
    "roles": ["role-uuid-hr-manager", "role-uuid-admin"]
  }
}

Note: The roles array contains role UUIDs, not human-readable names.


Policy Types

field_access

Controls which user roles can read or update specific fields on the component.

Config properties:

Property Type Description
fields string[] List of field keys this policy applies to
actions string[] Allowed actions: read, update
roles string[] Roles that are granted access to the specified fields

How it works:

When a user who is not an Owner or Maintainer reads or updates a field, the platform checks the component's enabled field_access policies:

  1. If the component has no enabled field_access policy at all, access is allowed.
  2. Otherwise access is allowed only if some enabled policy lists that field, lists the requested action (read or update), and lists a role the user holds.
  3. If no policy matches, the field is denied: it is removed from read results and left out of updates.

Once one policy is enabled, fields that no policy grants are denied to every non-admin role. Fields are matched by exact key; a wildcard such as "*" is not supported.

Example — Restrict sensitive fields:

{
  "type": "field_access",
  "name": "Financial Data Access",
  "enabled": true,
  "priority": 10,
  "config": {
    "fields": ["salary", "bank_account", "tax_id"],
    "actions": ["read", "update"],
    "roles": ["role-uuid-finance-team", "role-uuid-hr-manager"]
  }
}

Example — Read-only fields for specific roles:

{
  "type": "field_access",
  "name": "Allow View Only",
  "enabled": true,
  "priority": 5,
  "config": {
    "fields": ["salary"],
    "actions": ["read"],
    "roles": ["role-uuid-team-lead"]
  }
}

In this setup, a user with the role-uuid-team-lead role can view the salary field but cannot update it.

data_access (coming soon)

Controls access to data records based on custom filtering rules. Use this to restrict which records users can see or modify based on their role.

Info

data_access policies are not yet supported. This section is reserved for future implementation.

limits (coming soon)

Defines operational limits for the component, such as maximum number of records or rate limits for specific operations.

Info

limits policies are not yet supported. This section is reserved for future implementation.


Priority System

When multiple policies of the same type exist, they are listed in descending priority order (highest priority first). Access is granted when any enabled policy matches the field, the action and one of the user's roles, so priority does not change the outcome and policies only add access.

Several policies can grant different fields to different roles:

[
  {
    "type": "field_access",
    "name": "Full Access for HR",
    "enabled": true,
    "priority": 100,
    "config": {
      "fields": ["email", "name", "status", "salary"],
      "actions": ["read", "update"],
      "roles": ["role-uuid-hr-manager"]
    }
  },
  {
    "type": "field_access",
    "name": "Read-only for Support",
    "enabled": true,
    "priority": 50,
    "config": {
      "fields": ["email", "name", "status"],
      "actions": ["read"],
      "roles": ["role-uuid-support"]
    }
  }
]

Managing Policies

Policies have dedicated API endpoints and SDK methods for installation, updates, and deletion. This provides better control and validation compared to modifying the entire settings object.

API Endpoints

Get a Policy

GET /v4/system/component/{ref}/{version}/policies/{name}

Retrieves a single policy by name from the specified component version.

URL Parameters:

  • {ref} — Component reference (e.g., namespace::component-name)
  • {version} — Component version (e.g., 0.1.0)
  • {name} — Policy name

Response: 200 OK

{
  "type": "field_access",
  "name": "Restrict Salary Field",
  "description": "Only HR managers can access salary information",
  "enabled": true,
  "priority": 10,
  "config": {
    "fields": ["salary", "bonus"],
    "actions": ["read", "update"],
    "roles": ["role-uuid-hr-manager"]
  }
}

Error Responses:

  • 404 Not Found — Policy with the given name does not exist
  • 403 Forbidden — User lacks policies::read permission

Permissions Required: policies::read

Install a Policy

POST /v4/system/component/{ref}/{version}/policies

Request Body:

{
  "type": "field_access",
  "name": "Restrict Salary Field",
  "description": "Only HR managers can access salary information",
  "enabled": true,
  "priority": 10,
  "config": {
    "fields": ["salary", "bonus"],
    "actions": ["read", "update"],
    "roles": ["role-uuid-hr-manager"]
  }
}

Permissions Required: policies::create

Update a Policy

PATCH /v4/system/component/{ref}/{version}/policies/{name}

Request Body: (type, description, priority and config are merged when sent; enabled is always replaced by the value you send, so include it or the policy becomes disabled)

{
  "enabled": false,
  "priority": 20
}

Permissions Required: policies::edit

Delete a Policy

DELETE /v4/system/component/{ref}/{version}/policies/{name}

Permissions Required: policies::delete

Using the SDK

The SDK provides dedicated methods for managing policies:

Get a Policy

const component = new Component("my_component")

const policy = await component.getPolicy('Restrict Salary Field', '0.1.0')
console.log(policy.data)

Install a Policy

const component = new Component("my_component")

await component.installPolicy({
  type: "field_access",
  name: "Restrict Salary Field",
  description: "Only HR managers can access salary information",
  enabled: true,
  priority: 10,
  config: {
    fields: ["salary", "bonus"],
    actions: ["read", "update"],
    roles: ["role-uuid-hr-manager"]
  }
}, '0.1.0')

Update a Policy

// Always include `enabled`: it is replaced by the value you send
await component.updatePolicy('Restrict Salary Field', '0.1.0', {
  enabled: false,
  priority: 20
})

Delete a Policy

await component.deletePolicy('Restrict Salary Field', '0.1.0')

Viewing Policies

Policies are part of the component settings and can be retrieved using the standard settings endpoint:

const settings = await component.settings()
console.log(settings.policies)

Best Practices

  1. Grant every field you want visible — If no policies are enabled, all fields are accessible. As soon as one is enabled, fields that no policy grants are hidden from non-admin roles, so add a policy for the other fields too.
  2. Use meaningful names — Policy names should clearly describe what they control (e.g., "Restrict Financial Data" instead of "Policy 1").
  3. Grant read and update separately — A policy with only read lets a role see a field but not change it.
  4. Keep policies enabled/disabled — Instead of deleting policies, disable them. This makes it easy to re-enable them later.
  5. Test with non-admin users — Owners and Maintainers bypass all policy checks. Always test your policies with regular user roles.