The OpenFGA API accepts a JSON syntax for the configuration of the authorization model. The OpenFGA docs showcase an alternate friendlier syntax that can be used to build an OpenFGA authorization model.
This module transforms between the JSON syntax accepted by the OpenFGA API and the friendlier syntax you see throughout the documentation.
OpenFGA is an open source Fine-Grained Authorization solution inspired by Google's Zanzibar paper. It was created by the FGA team at Auth0 based on Auth0 Fine-Grained Authorization (FGA), available under a permissive license (Apache-2) and welcomes community contributions.
OpenFGA is designed to make it easy for application builders to model their permission layer, and to add and integrate fine-grained authorization into their applications. OpenFGA’s design is optimized for reliability and low latency at a high scale.
It allows in-memory data storage for quick development, as well as pluggable database modules - with initial support for PostgreSQL.
It offers an HTTP API and a gRPC API. It has SDKs for Node.js/JavaScript, GoLang, Python and .NET. Look in our Community section for third-party SDKs and tools.
More SDKs and integrations such as Rego are planned for the future.
- OpenFGA Documentation
- OpenFGA API Documentation
- OpenFGA Discord Community
- Zanzibar Academy
- Google's Zanzibar Paper (2019)
npm install --save @openfga/syntax-transformer // OR yarn add @openfga/syntax-transformer
const { friendlySyntaxToApiSyntax } = require("@openfga/syntax-transformer");
const apiSyntax = friendlySyntaxToApiSyntax(
`model
schema 1.1
type user
type document
relations
define blocked: [user]
define editor: [user] but not blocked
`);
const { apiSyntaxToFriendlySyntax } = require("@openfga/syntax-transformer");
const friendlySyntax = apiSyntaxToFriendlySyntax({
"schema_version": "1.1",
"type_definitions": [{
"type": "user",
"relations": {}
}, {
"type": "document",
"relations": {
"blocked": { "this": {} },
"editor": {
"difference": {
"base": { "this": {} },
"subtract": {
"computedUserset": {
"object": "",
"relation": "blocked"
}
}
}
}
},
"metadata": {
"relations": {
"blocked": {
"directly_related_user_types": [{ "type": "user" }]
},
"editor": {
"directly_related_user_types": [{ "type": "user" }]
}
}
}
}]
}
);
The two below Syntaxes are equivalent. Find out more on OpenFGA's configuration language here.
model
schema 1.1
type user
type folder
relations
define editor: [user]
type document
relations
define parent: [folder]
define editor: [user] or editor from parent
{
"schema_version": "1.1",
"type_definitions": [{
"type": "user",
"relations": {}
}, {
"type": "folder",
"relations": {
"editor": { "this": {} }
},
"metadata": {
"relations": {
"editor": {
"directly_related_user_types": [{ "type": "user" }]
}
}
}
}, {
"type": "document",
"relations": {
"parent": { "this": {} },
"editor": {
"union": {
"child": [{
"this": {}
}, {
"tupleToUserset": {
"tupleset": {
"object": "",
"relation": "parent"
},
"computedUserset": {
"object": "",
"relation": "editor"
}
}
}]
}
}
},
"metadata": {
"relations": {
"parent": {
"directly_related_user_types": [{ "type": "folder" }]
},
"editor": {
"directly_related_user_types": [{ "type": "user" }]
}
}
}
}]
}
The two below Syntaxes are equivalent. Find out more on OpenFGA's configuration language here.
type user
type folder
relations
define editor as self
type document
relations
define parent as self
define editor as self or editor from parent
{
"schema_version": "1.0",
"type_definitions": [{
"type": "user",
"relations": {}
}, {
"type": "folder",
"relations": {
"editor": { "this": {} }
}
}, {
"type": "document",
"relations": {
"parent": { "this": {} },
"editor": {
"union": {
"child": [{
"this": {}
}, {
"tupleToUserset": {
"tupleset": {
"object": "",
"relation": "parent"
},
"computedUserset": {
"object": "",
"relation": "editor"
}
}
}]
}
}
}
}]
}
Repo | License | Maintainers | Language | Schema v1.0 | Schema v1.1 | Package Managers | Other Links |
---|---|---|---|---|---|---|---|
syntax-transformer | Apache-2.0 | @openfga | Typescript | Yes | Yes | ||
openfga-dsl-parser | Apache-2.0 | @maxmindlin - @dblclik | Rust | Yes | No | WASM - Python | |
openfga-rs | Apache-2.0 | @iammathew | Rust | Yes | No |
Repo | License | Maintainers | Language | Schema v1.0 | Schema v1.1 | Package Managers | Other Links |
---|---|---|---|---|---|---|---|
fga-transformer-cli | MIT | @ozee-io | Javascript | Yes | Yes |
Take a look at our Contributing Guide
OpenFGA team