---
title: "How we built a custom permissions DSL at Figma"
description: "Figma replaced a sprawling Ruby `has_access?` permissions function with a custom, JSON-serializable permissions DSL and a cross-platform policy engine, inspired by AWS IAM policies."
url: "https://swe.quest/articles/how-we-built-a-custom-permissions-dsl-at-figma-b86982742becc83a"
canonical: "https://www.figma.com/blog/how-we-rolled-out-our-own-permissions-dsl-at-figma/"
source: "Figma"
published: "2024-03-13"
difficulty: "medium"
kind: "Case study"
reading_minutes: 24
tags: ["identity-auth","language-design","system-design","ruby","typescript"]
---

# How we built a custom permissions DSL at Figma

A post on [Figma](https://swe.quest/sources/figma.md), published 2024-03-13, 24 min read, Case study. Original: [https://www.figma.com/blog/how-we-rolled-out-our-own-permissions-dsl-at-figma/](https://www.figma.com/blog/how-we-rolled-out-our-own-permissions-dsl-at-figma/)

## Summary

Figma replaced a sprawling Ruby \`has\_access?\` permissions function with a custom, JSON-serializable permissions DSL and a cross-platform policy engine, inspired by AWS IAM policies. Each policy declares a resource type, an allow/deny effect, granular permissions and boolean conditions written as ExpressionDef triples that reference data fields such as \`file.deleted\_at\`. Because policies are pure data, the same rules run in both the Ruby/Sinatra backend and the TypeScript LiveGraph realtime layer, and data dependencies can be extracted statically. That separation decouples policy logic from data loading, letting rules be written and debugged independently and reducing database load from permission checks, which had been about 20% of total load.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [Language design](https://swe.quest/tags/language-design.md) (Compilers & runtimes)
- [System design](https://swe.quest/tags/system-design.md) (Architecture & design)
- [Ruby](https://swe.quest/tags/ruby.md) (Languages)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)

## Prerequisites

- authorization concepts ([easy posts on Identity & auth](https://swe.quest/tags/identity-auth.md?difficulty=easy))
- Ruby on Rails ActiveRecord ([easy posts on Ruby](https://swe.quest/tags/ruby.md?difficulty=easy))
- JSON

## Keywords

Figma, ExpressionDef, LiveGraph, AWS IAM, Sinatra, ActiveRecord, Open Policy Agent, Zanzibar

## Related posts

- [Visibility at scale: How Figma detects sensitive data exposure](https://swe.quest/articles/visibility-at-scale-how-figma-detects-sensitive-data-exposure-a9fbf43af9718cbb.md): Figma · 2025-10-23 · Medium · 11 min read · Application security, Identity & auth, Ruby, Privacy, Observability
  Figma built Response Sampling, a detection layer that randomly samples outbound API responses and checks them for sensitive data the requesting user shouldn't see.
- [Higher-level CRUD Abstraction for Postgres RLS](https://swe.quest/articles/higher-level-crud-abstraction-for-postgres-rls-90207e4bb081ead2.md): Neon · 2024-11-13 · Medium · 3 min read · PostgreSQL, Identity & auth, TypeScript
  Postgres Row-Level Security requires separate USING and WITH CHECK policies per operation, which gets repetitive for CRUD apps.
- [Modelling Authorization for a Social Network with Postgres RLS and Drizzle ORM](https://swe.quest/articles/modelling-authorization-for-a-social-network-with-postgres-rls-and-drizzle-orm-6267eb437b8171e7.md): Neon · 2024-11-11 · Medium · 8 min read · PostgreSQL, Identity & auth, TypeScript, System design
  Postgres Row-Level Security can express the full authorization model for a Twitter-like social network, defined with Drizzle ORM's crudPolicy and pgPolicy helpers and the pg\_session\_jwt extension's auth.user\_id().
- [A tale of two parameter architectures—and how we unified them](https://swe.quest/articles/a-tale-of-two-parameter-architectures-and-how-we-unified-them-9ac87b8fbe7bae01.md): Figma · 2025-07-29 · Medium · 11 min read · Design systems, System design, Refactoring & migrations
  Figma replaced the separate architectures behind component properties (scoped, layer-level parameters) and variables (global, library-level parameters) with one parametrization system.
- [How Figma manages sandboxes at scale](https://swe.quest/articles/how-figma-manages-sandboxes-at-scale-2d97e81a21201803.md): Figma · 2026-11-04 · Medium · 11 min read · Sandboxing & isolation, System design, Resilience, Cloud platforms, AI agents
  Nimbus is Figma's internal platform for running tens of thousands of sandboxes for AI-generated code across multiple cloud providers.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
