Skip to main content
This page covers Control Plane permissions - policies that control access to Formal’s web interface and APIs. For policies that control data access through Connectors (like database query policies), see the Policies section.

Introduction

Formal’s permission system is built on the Open Policy Agent (OPA), allowing you to restrict user access to specific applications through Rego policies. By defining granular permissions, you can ensure users have access only to the applications necessary for their roles and responsibilities. These permissions are enforced against our API endpoints.

Default permissions

Upon account creation, Formal operates under an allow-by-default model. Meaning, by default, if no permission blocks an endpoint for a given user, then the endpoint is allowed.
A Permission that leaves allow undefined doesn’t apply to the request. A Permission that can’t be evaluated blocks the request with an error: its code fails to compile, allow is both true and false, a built-in function errors, allow isn’t a boolean, or evaluation takes longer than 200ms. Code that fails to compile never blocks the Permissions API, so you can still fix or delete it.
  • Set default allow in every Permission.
  • Don’t make allow both true and false in one Permission. When both rules match, evaluation fails and the request is blocked.
  • Check input names against the list of inputs. A rule that misspells one never matches.

Permission actions

A Permission can block a request with an allow rule, or rewrite its response with a response rule. allow runs before the API handles the request. response runs after, only for requests that allow lets through.

Rewrite responses

A response rule replaces the response a user receives. Use it to hide list items, drop fields, or redact values. It has the same shape as the rewrite action of policies.
Users outside admin see only production resources and resources in one Space. The rule body decides when the rewrite applies, and keep_resource decides which items stay. Each keep_resource body is another way to keep an item. json is the whole replacement response, so start from input.response.json with object.union to keep the other fields. input.response.json uses the same camelCase field names as input.args. If a rewrite fails, the API returns an error instead of the original response. A rewrite fails when the rule errors, returns an action other than rewrite, or returns json that doesn’t match the response’s fields. It also fails when two Permissions rewrite the same response, so scope each response rule to the commands it’s for. A filtered page can hold fewer items than limit, or none. listMetadata.nextCursor is unchanged, so keep requesting pages until it’s empty. Rewrites apply only to unary API calls, and never to the Permissions application, so a broken rule can’t lock you out of fixing it. Rules can’t read fields the API marks sensitive, such as generated keys. Formal restores those fields after the rewrite, except inside list items. Totals such as technologySummaries still count hidden items. Hiding an item from a List command doesn’t hide it from Get, so add a rule for that command too.

Permission Model

Unlike other software products, Formal does not have the traditional concept of Roles. Instead, users can leverage Permissions to create role based access control (RBAC) using your organization’s Groups (which can be SCIM provisioned from your IDP into Formal).

User experience when blocked

The Formal APIs will return HTTP 403 error status codes if a user is blocked on a particular endpoint. Users who are interacting with the Formal APIs through the Control Plane will experience “Forbidden” toasts or dialogs.

List of inputs

You can block or allow requests based on the following user and application inputs:

User inputs

  • input.user.id
  • input.user.name
  • input.user.email
  • input.user.groups
  • input.user.ip_address
  • input.user.type (i.e. human or machine)
  • input.user.auth_method — how the request authenticated: browser_session, api_key, oidc, formal_sig, or oauth
  • input.user.oauth — the OAuth client acting for the user, present only when auth_method is oauth. See OAuth clients.

OAuth clients

An MCP client that connects to Formal MCP with OAuth calls the API as the user who approved it. Those calls carry input.user.oauth: An OAuth client reaches only the apps its scopes name, whatever Permissions allow, and only their read commands unless its scope for the app is write. Some writes stay out of its reach under any scope, as Formal MCP access lists. Permissions apply on top. See Keep MCP clients from deleting policies.

Application inputs

  • input.app.name
  • input.app.command.name
  • input.app.command.type
The permissions system also supports blocking or allowing requests based on the request payload for any API call based on input arguments (input.args). Argument keys use the API’s JSON field names in camelCase, such as input.args.spaceId and input.args.connectorId.

Response inputs

  • input.response.json — the API’s response, in the same JSON encoding as input.args. Set only while a response rule evaluates.

Target inputs

input.targets lists every Space, resource, connector, or satellite a resource, connector, or native user API request names, and every object under one:
  • the resource, connector, or child object it reads, updates, or deletes, for example DeleteResource or UpdateConnectorListener
  • the parent of an object it creates or lists, for example CreateNativeUserV3 and ListResourceHostnames name their resource
  • the object a link joins, for example CreateConnectorSatelliteLink names the connector and the satellite
  • the Space it assigns, for example spaceId on CreateResource, UpdateResource, CreateConnector, UpdateConnector, ListResources, and ListConnectors
Each target has:
  • type — for example resource, native_user_v3, connector_listener, or space
  • id — the ID from the request
  • space_id — the Space of the object, or of the resource or connector it belongs to. Empty when the object has no Space or does not exist.
  • resource_id — the resource the object is or belongs to, for example a native user’s resource. Absent for connectors and their objects.
  • connector_id — the connector the object is or belongs to, for example a listener rule’s connector. Absent for resources and their objects.
For example, this request moves a connector to another Space:
The permission sees the connector from id, with its current Space, and the new Space from spaceId:
input.targets is absent when the request names none of these objects, for example ListUsers, GetPolicy, or ListLogs. It is also absent for other APIs, such as UpdateSatelliteV2 or UpdateSpaceV2, even when their request includes a Space.

List of command types

Here is a table listing all command types that can be used. If the API call contains the operation, then it is categorized as the corresponding type.

List of applications

API endpoints are segmented into Applications. Here is a table listing all applications that can be configured for access permissions:

Public API

These applications have public API endpoints accessible via API keys or the Control Plane.
These applications are only accessible through the Control Plane and do not have public API documentation.
For Control Plane only applications, we recommend restricting access at the application level rather than by individual command types, since the available commands are not publicly documented.

Example: Single Application

Below is an example of a Rego policy that grants access to the Sessions application exclusively for users in the admin group.
This policy sets the default access to false, meaning no access is granted unless specified by a rule. The allow rule checks if the application requested is Sessions and if the user belongs to the admin group. If both conditions are met, access is granted.

Example: Granular Access Control

This multi-rule policy demonstrates how to combine different access levels:
  • Broad read access: Everyone can view most data using read command types.
  • Self-service access: Everyone can manage their own credentials in the Access app.
  • Administrative access: Users in security-admins have unrestricted access to all apps.
  • Team-specific access: Users in the engineers group can access developer-focused tools.
Since default allow = false is set, any request that does not match at least one of these allow rules is blocked. Formal returns a 403 Forbidden error for these requests.

Example: Argument-based Access Control

This policy blocks updates to the policy with the ID policy_01kg6rhpe7em4rr2v0mcwm0mp4 unless the user is in the security-admins group.

Example: Scope a machine user to one Space

Run one machine user per environment, for example one per Kubernetes cluster running the Kubernetes operator. This permission only lets the machine user call APIs whose targets are all in one Space:
The rule fails closed. A request with no targets is denied, so are logs, sessions, inventory, policies, permissions, and unfiltered lists. A request with any target outside the Space is denied, which covers moving an object into or out of the Space. To scope the machine user to one connector instead, compare target.connector_id to the connector’s ID. Resources and their objects have no connector_id, so that rule denies them. The operator also reads users and groups to build native user identity links, so org_reads allows ListUsers and ListGroups. Remove them if the cluster does not use identity links. Manage FormalPolicy objects from a cluster whose machine user is not scoped, since policies have no Space.

Example: Restrict Access to Logs

Viewing Connector, Desktop, Control Plane, and workflow logs all use the Logs application. There is no separate permission per log source.
Only users in security-admins can open Logs or call Logs APIs. For Control Plane audit fields and more permission patterns, see Control Plane Logs.

Example: Formal MCP only for pre-registered clients

Use input.user.oauth to decide which MCP clients may read through Formal MCP. Other ways of signing in are unaffected.

Example: Keep MCP clients from deleting policies

MCP clients you approve for write on Policies can change policies. Use input.user.oauth.scopes to narrow what they can do.
MCP clients can still create and update policies, but not delete them. People and API keys are unaffected.

Example: Show users only their own logs

Users outside security-admins see only their own log entries.

Example: Hide a resource’s hostname

Users outside admin get the resource without its hostname.

Example: Show users only the policies in one folder

Members of data-team see only the policies in the Data Team folder and its subfolders, in the Control Plane and through the API. folderPath is empty for a policy that is in no folder. The second rule hides the other folders from the folder list. totalPolicyCount still counts every policy.
These rules hide policies from lists. They do not block access by ID: GetPolicy still returns a hidden policy.