OpenFGA 是一套開源授權引擎。其文件指出,其模型語言的 JSON 形式(也就是 API 所接受的形式)“closely tracks the language in the Zanzibar paper”(緊密依循 Zanzibar 論文中的語言);DSL 則加入語法糖,並編譯為該 JSON(configuration language)。CNCF 宣布其進入孵化階段的文章指出,它 “was developed by a group of Okta employees, and is the foundation for the Auth0 FGA commercial offering”(由一群 Okta 員工開發,是 Auth0 FGA 商業產品的基礎)(CNCF,2025-11-11)。它以 Go 撰寫,採用 Apache-2.0 授權(儲存庫)。Auth0 的託管服務自稱 “based on OpenFGA, an open-source project owned by the Cloud Native Computing Foundation”(以 OpenFGA 為基礎,這是一個由 Cloud Native Computing Foundation 擁有的開源專案)(Auth0 FGA docs)。
論文術語與 OpenFGA 術語
OpenFGA 自己的文件中有一張 “Equivalent Zanzibar Concepts”(對應的 Zanzibar 概念)表(configuration language);本表將其延伸到 API 與儲存層。
| 論文中 | OpenFGA 中 |
|---|---|
| 命名空間設定(§2.3) | 授權模型中的一個 type,以 DSL 或 JSON 撰寫(configuration language) |
關係元組 object#relation@user(§2.1) |
由 user、relation、object 組成的 relationship tuple,例如 user:anne、owner、doc:readme;使用者集合寫成 group:eng#member |
_this(§2.3.1) |
直接型別限制,例如 [user, group#member](JSON 中為 this) |
computed_userset |
直接寫關係名稱,例如 or owner |
tuple_to_userset |
viewer from parent(JSON 中為 tupleToUserset) |
union / intersection / exclusion |
or / and / but not(JSON 中為 union / intersection / difference) |
| zookie(§2.4) | 無;查詢選擇 MINIMIZE_LATENCY 或 HIGHER_CONSISTENCY(consistency) |
| Check(§2.4.4) | Check、BatchCheck |
| Read(§2.4.1) | Read |
| Write(§2.4.2) | Write |
| Watch(§2.4.3) | ReadChanges,以接續權杖分頁讀取清單(tuple changes) |
| Expand(§2.4.5) | Expand |
| 不在論文的 API 中 | ListObjects、StreamedListObjects、ListUsers;store;模型版本(WriteAuthorizationModel、ReadAuthorizationModel(s)) |
| Leopard(§3.2.4) | 此處引用的文件中沒有對應物 |
| Spanner(§3) | memory(預設)、postgres、mysql、sqlite(configure OpenFGA) |
API 名稱出自 openfga_service.proto。
以模型表示貫穿全站的範例
論文的圖 1 讓擁有者成為編輯者、編輯者成為檢視者,並讓上層資料夾的檢視者成為文件的檢視者(§2.3.1)。在 OpenFGA 的 DSL 中,同樣的規則每個關係只佔一行:
model
schema 1.1
type user
type group
relations
define member: [user]
type folder
relations
define viewer: [user, group#member]
type doc
relations
define parent: [folder]
define owner: [user]
define editor: [user, group#member] or owner
define viewer: [user, group#member] or editor or viewer from parent
Anne、Beto 與 Chen 的元組:
| user | relation | object |
|---|---|---|
user:anne |
owner |
doc:readme |
folder:A |
parent |
doc:readme |
user:beto |
member |
group:eng |
group:eng#member |
viewer |
doc:readme |
user:chen |
viewer |
folder:A |
對 readme 進行 viewer 檢查時,每個人各會走過其中哪些元組?
請注意,承載「擁有者是編輯者」與「編輯者是檢視者」的是模型,而不是元組:這正是論文的論點,即關係之間的關係屬於設定,而不是每個物件一筆元組(§2.3.1)。
架構
一套 OpenFGA 部署由什麼組成?文件描述的是共用一個 SQL 資料儲存區的多台伺服器。每台伺服器都可以為 Check 保有記憶體內快取,而正式環境指南建議使用 “a small pool of servers with high capacity (memory and CPU cores) instead of a big pool of servers, to increase cache hit ratios”(少量但高容量(記憶體與 CPU 核心)的伺服器,而非大量伺服器,以提高快取命中率)(running in production)。對於 PostgreSQL,可以設定一個次要(唯讀副本)資料儲存區;HIGHER_CONSISTENCY 讀取會送往主資料儲存區(configure OpenFGA)。變更的消費者呼叫 ReadChanges 並保存接續權杖(tuple changes)。
對照論文的圖 2(§3):aclservers 彼此扇出工作,watchservers 推送串流,Leopard 維護一個反正規化的索引。此處引用的 OpenFGA 文件三者都沒有描述;伺服器從資料儲存區與自己的快取回答。
沒有 zookie 的一致性
OpenFGA 沒有 zookie。其文件在 “Future work”(未來工作)下說明了這一點:論文 “has a feature called Zookies”(有一項稱為 Zookies 的功能),而 OpenFGA “is considering a similar feature in future releases”(正在考慮於未來版本中加入類似的功能)(consistency)。取而代之的是,Read 與查詢 API 接受以下兩個值之一:
| 模式 | 行為(consistency 文件) | 論文中的對應 |
|---|---|---|
MINIMIZE_LATENCY(預設) |
“will serve queries from the cache when possible”(在可能時從快取提供查詢結果) | 不帶 zookie 的請求:“a reasonably recent snapshot”(相當新的快照)(§2.4.1) |
HIGHER_CONSISTENCY |
“will skip the cache and query the database directly”(略過快取,直接查詢資料庫) | 沒有完全對應者;最接近的是在最新快照上評估 |
快取 “disabled by default”(預設停用),此時 “all queries will have strong consistency regardless of the consistency mode specified”(無論指定哪種一致性模式,所有查詢都具有強一致性)(consistency)。只有在開啟快取之後,模式才有意義。
在快取開啟的情況下,Chen 從資料夾 A 中被移除後,是否仍能立即看到 readme?
文件建議逐請求決定:如果應用程式記錄了資源最後被修改的時間,就可以將該時間與快取 TTL 比較,以在兩種模式之間選擇(consistency)。這個時間戳記扮演了 zookie 的部分角色,由應用程式保存。另外也有快取失效旗標(cache-controller-enabled),會檢查 store 最近是否有寫入。
與論文的差異
- 沒有 zookie。 不傳回也不接受任何一致性權杖;取而代之的是兩種模式加上一個預設關閉的快取(consistency)。論文的一致性模型建立在 zookie 之上(§2.2)。
- 變更以輪詢取得。
ReadChanges傳回一頁 “sorted by ascending time”(依時間遞增排序)的元組變更,並附上接續權杖(openfga_service.proto)。論文的 Watch 是帶有心跳 zookie 的串流(§2.4.3)。 - 儲存。 論文使用 Spanner(§3.1)。OpenFGA 提供
memory(預設,“Data is lost between server restarts”,伺服器重新啟動後資料會遺失)、PostgreSQL(可選用唯讀副本)、MySQL 與 SQLite(configure OpenFGA)。 - 條件。 像
[user with non_expired_grant]這樣的型別限制,讓元組只在某個 CEL 條件成立時才計入(conditions)。論文的元組(§2.1)沒有條件。 - 情境元組。 隨單一 Check、ListObjects、ListUsers 或 Expand 請求送出的元組,“not persisted in the datastore”(不會永久儲存到資料儲存區中)(concepts、contextual tuples)。
- 萬用字元。
[user, user:*]允許公開授權(configuration language);論文的元組文法沒有萬用字元(§2.1)。 - store 與模型版本。 一個 store 存放 “one or more versions of an authorization model”(授權模型的一個或多個版本)及其元組;“Store data cannot be shared across stores”(store 的資料無法跨 store 共用)(concepts)。在論文中,設定存放在一張以命名空間 ID 為鍵的表中,旁邊是設定更新的變更日誌,而每個請求都在單一的設定快照時間戳記上評估(§3.1.3、§3.2.2)。OpenFGA 的檢查可以指名它所使用的模型版本。
- 沒有 Leopard。 此處引用的文件描述的是 Check 快取與 iterator 快取,而不是像 Leopard 那樣預先計算的集合索引(§3.2.4)。
- 列出 API。
ListObjects、StreamedListObjects與ListUsers不在論文的 API 之中(§2.4)。
狀態
截至 2026-11-13:活躍。最新版本 v1.22.1,發布於 2026-10-28;首個版本 v0.1.0 發布於 2022-06-10;GitHub 星數約 6.1k;Apache-2.0(儲存庫、releases)。
- 2022 年 6 月:開源(專案文章,2026-01-07)。
- 2022 年:被接受為 CNCF Sandbox 專案。來源之間的日期不一致:CNCF 的專案頁面說 OpenFGA “was accepted to CNCF on September 14, 2022”(於 2022 年 9 月 14 日被 CNCF 接受),其公告說是 2022 年 9 月;專案自己的文章則說是 2022 年 12 月(CNCF project page、CNCF、專案文章)。
- 2025-10-28:依 CNCF 專案頁面,晉升到 Incubating 成熟度等級。
- 2025-11-11:CNCF 宣布其技術監督委員會 “has voted to accept OpenFGA as a CNCF incubating project”(已投票接受 OpenFGA 成為 CNCF 孵化專案)(CNCF)。
- 託管服務為 Auth0 FGA(docs)。
資料來源
- https://github.com/openfga/openfga
- https://github.com/openfga/openfga/releases
- https://openfga.dev/docs
- https://openfga.dev/docs/concepts
- https://openfga.dev/docs/configuration-language
- https://openfga.dev/docs/interacting/consistency
- https://openfga.dev/docs/interacting/read-tuple-changes
- https://openfga.dev/docs/interacting/contextual-tuples
- https://openfga.dev/docs/modeling/conditions
- https://openfga.dev/docs/best-practices/running-in-production
- https://openfga.dev/docs/getting-started/setup-openfga/configure-openfga
- https://github.com/openfga/api/blob/main/openfga/v1/openfga_service.proto
- https://github.com/openfga/sample-stores/blob/main/stores/gdrive/model.fga
- https://openfga.dev/blog/incubation-announcement
- https://www.cncf.io/blog/2025/11/11/openfga-becomes-a-cncf-incubating-project/
- https://www.cncf.io/projects/openfga/
- https://docs.fga.dev/fga