Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/markdown.links.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
},
{
"pattern": "https://github.com/openfga/dotnet-sdk"
},
{
"pattern": "https://github.com/openfga/python-sdk"
},
{
"pattern": "https://pypi.org/project/openfga-sdk"
}
],
"httpHeaders": [
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ hide_title: true

## About OpenFGA

[OpenFGA](https://github.com/openfga/openfga) is an open source Fine-Grained Authorization solution based on Google's Zanzibar. It was created by the Auth0 FGA team and welcomes community contribution. OpenFGA is designed to make it easy for application builders to quickly add fine-grained authorization to their applications. It offers an HTTP API and has SDKs for programming languages including [JavaScript](https://github.com/openfga/js-sdk), [GoLang](https://github.com/openfga/go-sdk) and [.NET](https://github.com/openfga/dotnet-sdk). More SDKs and integrations such as Rego are planned for the future. OpenFGA is designed and optimized for reliability and low latency at a high scale.
[OpenFGA](https://github.com/openfga/openfga) is an open source Fine-Grained Authorization solution based on Google's Zanzibar. It was created by the Auth0 FGA team and welcomes community contribution. OpenFGA is designed to make it easy for application builders to quickly add fine-grained authorization to their applications. It offers an HTTP API and has SDKs for programming languages including [JavaScript](https://github.com/openfga/js-sdk), [GoLang](https://github.com/openfga/go-sdk), [.NET](https://github.com/openfga/dotnet-sdk) and [Python](https://github.com/openfga/python-sdk). More SDKs and integrations such as Rego are planned for the future. OpenFGA is designed and optimized for reliability and low latency at a high scale.

## Resources

Expand Down
2 changes: 1 addition & 1 deletion docs/content/authorization-and-openfga.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This section explains [authorization](#authentication-vs-authorization), [fine-g

## What Is OpenFGA?

**OpenFGA** is an open source solution to [Fine-Grained Authorization](#what-is-fine-grained-authorization-fga) that applies the concept of [ReBAC](#what-is-relationship-based-access-control-rebac). It was created by the [Auth0 FGA](https://docs.fga.dev/) team and was inspired by [Zanzibar](#what-is-zanzibar). It was designed for reliability and low latency at a high scale. It offers an HTTP API and has SDKs for programming languages including [Node.js/JavaScript](https://www.npmjs.com/package/@openfga/sdk), [GoLang](https://github.com/openfga/go-sdk) and [.NET](https://www.nuget.org/packages/OpenFga.Sdk). More SDKs and integrations such as Rego are planned for the future.
**OpenFGA** is an open source solution to [Fine-Grained Authorization](#what-is-fine-grained-authorization-fga) that applies the concept of [ReBAC](#what-is-relationship-based-access-control-rebac). It was created by the [Auth0 FGA](https://docs.fga.dev/) team and was inspired by [Zanzibar](#what-is-zanzibar). It was designed for reliability and low latency at a high scale. It offers an HTTP API and has SDKs for programming languages including [Node.js/JavaScript](https://www.npmjs.com/package/@openfga/sdk), [GoLang](https://github.com/openfga/go-sdk), [.NET](https://www.nuget.org/packages/OpenFga.Sdk) and [Python](https://pypi.org/project/openfga-sdk). More SDKs and integrations such as Rego are planned for the future.

<Playground intro={true} />

Expand Down
3 changes: 2 additions & 1 deletion docs/content/getting-started/configure-model.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ This article explains how to configure an <ProductConcept section="what-is-an-au
## Before You Start

<Tabs groupId="languages">
{[SupportedLanguage.JS_SDK, SupportedLanguage.GO_SDK, SupportedLanguage.DOTNET_SDK].map(lang =>
{[SupportedLanguage.JS_SDK, SupportedLanguage.GO_SDK, SupportedLanguage.DOTNET_SDK, SupportedLanguage.PYTHON_SDK].map(lang =>
<TabItem value={lang} label={languageLabelMap.get(lang)}>

1. <SdkSetupPrerequisite />
Expand Down Expand Up @@ -97,6 +97,7 @@ To configure authorization model, we can invoke the [write authorization models
SupportedLanguage.JS_SDK,
SupportedLanguage.GO_SDK,
SupportedLanguage.DOTNET_SDK,
SupportedLanguage.PYTHON_SDK,
SupportedLanguage.CURL,
]}
/>
Expand Down
32 changes: 32 additions & 0 deletions docs/content/getting-started/create-store.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,38 @@ class MyProgram {

</TabItem>

<TabItem value={SupportedLanguage.PYTHON_SDK} label={languageLabelMap.get(SupportedLanguage.PYTHON_SDK)}>

```python
import os
import openfga_sdk
from openfga_sdk.api import open_fga_api
from openfga_sdk.models.create_store_request import CreateStoreRequest


configuration = openfga_sdk.Configuration(
scheme = os.environ.get('FGA_API_SCHEME')
api_host = os.environ.get('FGA_API_HOST'),
)

# Create an instance of the API class
fga_client_instance = open_fga_api.OpenFgaApi(openfga_sdk.ApiClient(configuration))

async def create_store():
try:
# Create a store
body = CreateStoreRequest(
name = "FGA Demo",
)
api_response = await fga_client_instance.create_store(body)
except openfga_sdk.ApiException as e:
print("Exception when calling OpenFgaApi->create_store: %s\n" % e)

```

</TabItem>


<TabItem value={SupportedLanguage.CURL} label={languageLabelMap.get(SupportedLanguage.CURL)}>

```console
Expand Down
22 changes: 22 additions & 0 deletions docs/content/getting-started/install-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,23 @@ Install-Package OpenFGA.Sdk

- [Visual Studio](https://docs.microsoft.com/en-us/nuget/consume-packages/install-use-packages-visual-studio), [Visual Studio for Mac](https://docs.microsoft.com/en-us/visualstudio/mac/nuget-walkthrough) and [IntelliJ Rider](https://www.jetbrains.com/help/rider/Using_NuGet.html): Search for and install `OpenFGA.Sdk` in each of their respective package manager UIs.

</TabItem>
<TabItem value={SupportedLanguage.PYTHON_SDK} label={languageLabelMap.get(SupportedLanguage.PYTHON_SDK)}>

The <ProductName format={ProductNameFormat.ShortForm}/> Python SDK is available on [PyPI](https://pypi.org/project/openfga-sdk).

To install:

```
pip3 install openfga_sdk
```

In your code, import the module and use it:

```python
import openfga_sdk
```

</TabItem>
</Tabs>

Expand All @@ -126,5 +143,10 @@ Install-Package OpenFGA.Sdk
description: 'Connect your .NET service with {ProductName} using our .NET SDK',
link: 'https://github.com/openfga/dotnet-sdk',
},
{
title: '{ProductName} Python SDK',
description: 'Connect your Python service with {ProductName} using our .NET SDK',
link: 'https://github.com/openfga/python-sdk',
},
]}
/>
8 changes: 7 additions & 1 deletion docs/content/getting-started/perform-check.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This section will illustrate how to perform a <ProductConcept section="what-is-a
## Before You Start

<Tabs groupId="languages">
{[SupportedLanguage.JS_SDK, SupportedLanguage.GO_SDK, SupportedLanguage.DOTNET_SDK].map(lang =>
{[SupportedLanguage.JS_SDK, SupportedLanguage.GO_SDK, SupportedLanguage.DOTNET_SDK, SupportedLanguage.PYTHON_SDK].map(lang =>
<TabItem value={lang} label={languageLabelMap.get(lang)}>

1. <SdkSetupPrerequisite />
Expand Down Expand Up @@ -70,6 +70,11 @@ Before calling the check API, you will need to configure the API client.

<SdkSetupHeader lang={SupportedLanguage.DOTNET_SDK} />

</TabItem>
<TabItem value={SupportedLanguage.PYTHON_SDK} label={languageLabelMap.get(SupportedLanguage.PYTHON_SDK)}>

<SdkSetupHeader lang={SupportedLanguage.PYTHON_SDK} />

</TabItem>
<TabItem value={SupportedLanguage.CURL} label={languageLabelMap.get(SupportedLanguage.CURL)}>

Expand All @@ -94,6 +99,7 @@ To check whether user `anne` has relationship `reader` with object `document:Z`
SupportedLanguage.JS_SDK,
SupportedLanguage.GO_SDK,
SupportedLanguage.DOTNET_SDK,
SupportedLanguage.PYTHON_SDK,
SupportedLanguage.CURL,
]}
/>
Expand Down
43 changes: 43 additions & 0 deletions docs/content/getting-started/setup-sdk-client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,26 @@ class MyProgram {
```

</TabItem>
<TabItem value={SupportedLanguage.PYTHON_SDK} label={languageLabelMap.get(SupportedLanguage.PYTHON_SDK)}>

```python
import os
import openfga_sdk
from openfga_sdk.api import open_fga_api

configuration = openfga_sdk.Configuration(
api_scheme = os.environ.get('FGA_API_SCHEME')
api_host = os.environ.get('FGA_API_HOST'),
store_id = os.environ.get('FGA_STORE_ID')
)

# Create an instance of the API class
fga_client_instance = open_fga_api.OpenFgaApi(openfga_sdk.ApiClient(configuration))

```

</TabItem>

</Tabs>

## Using Shared Key Authentication
Expand Down Expand Up @@ -167,5 +187,28 @@ class MyProgram {
}
```

</TabItem>
<TabItem value={SupportedLanguage.PYTHON_SDK} label={languageLabelMap.get(SupportedLanguage.PYTHON_SDK)}>

```python
import os
import openfga_sdk
from openfga_sdk.api import open_fga_api
from open_fga_api.credentials import Credentials, CredentialConfiguration


credentials = Credentials(method='api_token',
configuration=CredentialConfiguration(api_token=os.environ.get(FGA_BEARER_TOKEN)))
configuration = openfga_sdk.Configuration(
api_scheme = os.environ.get(FGA_API_SCHEME), # optional, defaults to "https"
api_host = os.environ.get(FGA_API_HOST), # required, define without the scheme (e.g. api.openfga.example instead of https://api.openfga.example)
store_id = os.environ.get(FGA_STORE_ID), # optional, not needed for `CreateStore` and `ListStores`, required before calling for all other methods
credentials = credentials)

# Create an instance of the API class
fga_client_instance = open_fga_api.OpenFgaApi(openfga_sdk.ApiClient(configuration))

```

</TabItem>
</Tabs>
9 changes: 8 additions & 1 deletion docs/content/getting-started/update-tuples.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ This section will illustrate how to update _<ProductConcept section="what-is-a-r
## Before You Start

<Tabs groupId="languages">
{[SupportedLanguage.JS_SDK, SupportedLanguage.GO_SDK, SupportedLanguage.DOTNET_SDK].map(lang =>
{[SupportedLanguage.JS_SDK, SupportedLanguage.GO_SDK, SupportedLanguage.DOTNET_SDK, SupportedLanguage.PYTHON_SDK].map(lang =>
<TabItem value={lang} label={languageLabelMap.get(lang)}>

1. <SdkSetupPrerequisite />
Expand Down Expand Up @@ -78,6 +78,11 @@ Before calling the write API, you will need to configure the API client.

<SdkSetupHeader lang={SupportedLanguage.DOTNET_SDK} />

</TabItem>
<TabItem value={SupportedLanguage.PYTHON_SDK} label={languageLabelMap.get(SupportedLanguage.PYTHON_SDK)}>

<SdkSetupHeader lang={SupportedLanguage.PYTHON_SDK} />

</TabItem>
<TabItem value={SupportedLanguage.CURL} label={languageLabelMap.get(SupportedLanguage.CURL)}>

Expand Down Expand Up @@ -105,6 +110,7 @@ To add the relationship tuples, we can invoke the write API.
SupportedLanguage.JS_SDK,
SupportedLanguage.GO_SDK,
SupportedLanguage.DOTNET_SDK,
SupportedLanguage.PYTHON_SDK,
SupportedLanguage.CURL,
]}
/>
Expand Down Expand Up @@ -136,6 +142,7 @@ Assume that you want to delete user `anne`'s `reader` relationship with object `
SupportedLanguage.JS_SDK,
SupportedLanguage.GO_SDK,
SupportedLanguage.DOTNET_SDK,
SupportedLanguage.PYTHON_SDK,
SupportedLanguage.CURL,
]}
/>
Expand Down
26 changes: 22 additions & 4 deletions docs/content/interacting/read-tuple-changes.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ This section illustrates how to call the Read Changes API to get the list of rel
1. <SdkSetupPrerequisite />
2. You have [installed the SDK](../getting-started/install-sdk.mdx).
3. You have [configured the _authorization model_](../modeling) and [added some _relationship tuples_](../getting-started/update-tuples.mdx#02-calling-write-api-to-add-new-relationship-tuples).
4. You have loaded `FGA_ENVIRONMENT`, `FGA_STORE_ID`, `FGA_CLIENT_ID` and `FGA_CLIENT_SECRET` as environment variables.
4. You have loaded `FGA_STORE_ID` and `FGA_API_HOST` as environment variables.

</TabItem>
<TabItem value={SupportedLanguage.GO_SDK} label={languageLabelMap.get(SupportedLanguage.GO_SDK)}>

1. <SdkSetupPrerequisite />
2. You have [installed the SDK](../getting-started/install-sdk.mdx).
3. You have [configured the _authorization model_](../modeling) and [added some _relationship tuples_](../getting-started/update-tuples.mdx#02-calling-write-api-to-add-new-relationship-tuples).
4. You have loaded `FGA_ENVIRONMENT`, `FGA_STORE_ID`, `FGA_CLIENT_ID` and `FGA_CLIENT_SECRET` as environment variables.
4. You have loaded `FGA_STORE_ID` and `FGA_API_HOST` as environment variables.

</TabItem>

Expand All @@ -49,14 +49,22 @@ This section illustrates how to call the Read Changes API to get the list of rel
1. <SdkSetupPrerequisite />
2. You have [installed the SDK](../getting-started/install-sdk.mdx).
3. You have [configured the _authorization model_](../modeling).
4. You have loaded `FGA_ENVIRONMENT`, `FGA_STORE_ID`, `FGA_CLIENT_ID` and `FGA_CLIENT_SECRET` as environment variables.
4. You have loaded `FGA_STORE_ID` and `FGA_API_HOST` as environment variables.

</TabItem>
<TabItem value={SupportedLanguage.PYTHON_SDK} label={languageLabelMap.get(SupportedLanguage.PYTHON_SDK)}>

1. <SdkSetupPrerequisite />
2. You have [installed the SDK](../getting-started/install-sdk.mdx).
3. You have [configured the _authorization model_](../modeling).
4. You have loaded `FGA_STORE_ID` and `FGA_API_HOST` as environment variables.

</TabItem>
<TabItem value={SupportedLanguage.CURL} label={languageLabelMap.get(SupportedLanguage.CURL)}>

1. <SdkSetupPrerequisite />
2. You have [configured the _authorization model_](../modeling) and [added some _relationship tuples_](../getting-started/update-tuples.mdx#02-calling-write-api-to-add-new-relationship-tuples).
3. You have loaded `FGA_ENVIRONMENT`, `FGA_BEARER_TOKEN` and `FGA_STORE_ID` as environment variables.
3. You have loaded `FGA_STORE_ID` and `FGA_API_HOST` as environment variables.

</TabItem>
</Tabs>
Expand Down Expand Up @@ -87,6 +95,12 @@ First you will need to configure the API client.

</TabItem>

<TabItem value={SupportedLanguage.PYTHON_SDK} label={languageLabelMap.get(SupportedLanguage.PYTHON_SDK)}>

<SdkSetupHeader lang="python-sdk" />

</TabItem>

<TabItem value={SupportedLanguage.CURL} label={languageLabelMap.get(SupportedLanguage.CURL)}>

To obtain the [access token](https://auth0.com/docs/authorization/flows/call-your-api-using-the-client-credentials-flow):
Expand All @@ -108,6 +122,7 @@ To get a paginated list of changes that happened in your store:
SupportedLanguage.JS_SDK,
SupportedLanguage.GO_SDK,
SupportedLanguage.DOTNET_SDK,
SupportedLanguage.PYTHON_SDK,
SupportedLanguage.CURL,
]}
/>
Expand All @@ -124,6 +139,7 @@ You can then use this token to get the next set of changes:
SupportedLanguage.JS_SDK,
SupportedLanguage.GO_SDK,
SupportedLanguage.DOTNET_SDK,
SupportedLanguage.PYTHON_SDK,
SupportedLanguage.CURL,
]}
/>
Expand Down Expand Up @@ -182,6 +198,7 @@ It is possible to get a list of changes that happened in your store that relate
SupportedLanguage.JS_SDK,
SupportedLanguage.GO_SDK,
SupportedLanguage.DOTNET_SDK,
SupportedLanguage.PYTHON_SDK,
SupportedLanguage.CURL,
]}
/>
Expand All @@ -197,6 +214,7 @@ The response will include a continuation token. In subsequent calls, you have to
SupportedLanguage.JS_SDK,
SupportedLanguage.GO_SDK,
SupportedLanguage.DOTNET_SDK,
SupportedLanguage.PYTHON_SDK,
SupportedLanguage.CURL,
]}
/>
8 changes: 8 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ using OpenFga.Sdk.Configuration;`,
apiName: `OpenFgaApi`,
setupNote: `// ApiTokenIssuer, ApiAudience, ClientId and ClientSecret are optional.\n`,
},
python: {
importStatement: `import os
import json
import openfga_sdk
from openfga_sdk.api import open_fga_api`,
apiName: `OpenFgaApi`,
setupNote: `# ApiTokenIssuer, ApiAudience, ClientId and ClientSecret are optional.\n`,
}
},
contentSecurityPolicy: `default-src 'none';
base-uri 'self';
Expand Down
32 changes: 32 additions & 0 deletions src/components/Docs/SnippetViewer/CheckRequestViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,37 @@ var response = await fgaClient.Check(new CheckRequest(new TupleKey() {
});

// response.Allowed = ${allowed}`;
case SupportedLanguage.PYTHON_SDK:
return `
# from openfga_sdk.models.check_request import CheckRequest
# from openfga_sdk.models.tuple_key import TupleKey
# from openfga_sdk.models.contextual_tuple_keys import ContextualTupleKeys

# Run a check
async def check():
body = CheckRequest(
tuple_key=TupleKey(
user="${user}",
relation="${relation}",
object="${object}",
), ${
contextualTuples
? `
contextual_tuples=ContextualTupleKeys(
tuple_keys=[
${contextualTuples
.map(
(tuple) => `TupleKey(user="${tuple.user}", relation="${tuple.relation}", object="${tuple.object}")`,
)
.join(',\n ')}
],
),`
: ``
}
)
response = await fga_client_instance.check(body)
# response.allowed = ${allowed}
`;
case SupportedLanguage.RPC:
return `check(
"${user}", // check if the user \`${user}\`
Expand Down Expand Up @@ -156,6 +187,7 @@ export function CheckRequestViewer(opts: CheckRequestViewerOpts): JSX.Element {
SupportedLanguage.JS_SDK,
SupportedLanguage.GO_SDK,
SupportedLanguage.DOTNET_SDK,
SupportedLanguage.PYTHON_SDK,
SupportedLanguage.CURL,
SupportedLanguage.RPC,
];
Expand Down
Loading