title | description | slug |
---|---|---|
Configure Authorization Model |
Configuring authorization model for a store |
/getting-started/configure-model |
import { AuthzModelSnippetViewer, DocumentationNotice, languageLabelMap, ProductConcept, ProductName, ProductNameFormat, RelatedSection, SdkSetupPrerequisite, SupportedLanguage, WriteAuthzModelViewer, } from '@components/Docs'; import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
This article explains how to configure an for a in an OpenFGA server.
- You have installed the SDK, created the store and setup the SDK client.
- You have loaded
FGA_STORE_ID
andFGA_API_HOST
as environment variables.
- You have installed the SDK, created the store and setup the SDK client.
- You have loaded
FGA_STORE_ID
andFGA_API_HOST
as environment variables.
- You have installed the SDK, created the store and setup the SDK client.
- You have loaded
FGA_STORE_ID
andFGA_API_HOST
as environment variables.
- You have installed the SDK, created the store and setup the SDK client.
- You have loaded
FGA_STORE_ID
andFGA_API_HOST
as environment variables.
- You have installed the SDK, created the store and setup the SDK client.
- You have loaded
FGA_STORE_ID
andFGA_API_HOST
as environment variables.
- You have installed the CLI, created the store and setup your environment variables.
- You have loaded
FGA_STORE_ID
andFGA_SERVER_URL
as environment variables.
- You have created the store and have loaded
FGA_STORE_ID
andFGA_API_HOST
as environment variables.
Assume that you want to configure your store with the following model.
<AuthzModelSnippetViewer configuration={{ schema_version: '1.1', type_definitions: [ { type: 'user', }, { type: 'document', relations: { reader: { this: {}, }, writer: { this: {}, }, owner: { this: {}, }, }, metadata: { relations: { reader: { directly_related_user_types: [{ type: 'user' }] }, writer: { directly_related_user_types: [{ type: 'user' }] }, owner: { directly_related_user_types: [{ type: 'user' }] }, }, }, }, ], }} />
To configure authorization model, we can invoke the write authorization models API.
<WriteAuthzModelViewer authorizationModel={{ schema_version: '1.1', type_definitions: [ { type: 'user', }, { type: 'document', relations: { reader: { this: {}, }, writer: { this: {}, }, owner: { this: {}, }, }, metadata: { relations: { reader: { directly_related_user_types: [{ type: 'user' }] }, writer: { directly_related_user_types: [{ type: 'user' }] }, owner: { directly_related_user_types: [{ type: 'user' }] }, }, }, }, ], }} allowedLanguages={[ SupportedLanguage.JS_SDK, SupportedLanguage.GO_SDK, SupportedLanguage.DOTNET_SDK, SupportedLanguage.PYTHON_SDK, SupportedLanguage.JAVA_SDK, SupportedLanguage.CLI, SupportedLanguage.CURL, ]} />
The API will then return the authorization model ID.
:::info Note The OpenFGA API only accepts an authorization model in the API's JSON syntax.
To convert between the API Syntax and the friendly DSL, you can use the FGA CLI. :::
<RelatedSection description="Take a look at the following sections for more information on how to configure authorization model in your store." relatedLinks={[ { title: 'Getting Started with Modeling', description: 'Read how to get started with modeling.', link: '../modeling/getting-started', }, { title: 'Modeling: Direct Relationships', description: 'Read the basics of modeling authorization and granting access to users.', link: '../modeling/direct-access', }, ]} />