Skip to content

feat: add Playground RFC#35

Open
rhamzeh wants to merge 1 commit into
mainfrom
feat/add-playground-rfc
Open

feat: add Playground RFC#35
rhamzeh wants to merge 1 commit into
mainfrom
feat/add-playground-rfc

Conversation

@rhamzeh

@rhamzeh rhamzeh commented May 13, 2026

Copy link
Copy Markdown
Member

Description

This RFC proposes a new, fully open-source OpenFGA Playground that replaces the current hosted iframe experience with a locally run, modular app. It introduces a pluggable architecture (direct,future proxy, and future WASM backends), reusable Web Components, and a richer feature set for modeling, testing, visualization, and debugging. The goal is to eliminate recurring user friction due to CORS or it being in an iframe or remotely hosted, improve maintainability, and make the playground embeddable across docs and developer tooling while keeping the core UX familiar for existing users.

What problem is being solved?

How is it being solved?

What changes are made to solve it?

References

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

Copilot AI review requested due to automatic review settings May 13, 2026 23:52
@rhamzeh rhamzeh force-pushed the feat/add-playground-rfc branch from 0da2839 to 7ec6001 Compare May 13, 2026 23:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new draft RFC proposing an open-source OpenFGA Playground architecture, covering deployment surfaces, backend adapter design, fga serve proxy concepts, shared config, and alternatives.

Changes:

  • Introduces a full Playground RFC document.
  • Defines proposed packages, adapters, proxy endpoints, security layers, drawbacks, alternatives, and unresolved questions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread 20260326-playground.md

### Architecture overview

The playground shell talks to the OpenFGA API through a pluggable `BackendAdapter` interface. Three adapters ship with the project, each suited to a different deployment mode. In all three cases, the shell is identical and only the adapter changes.
Comment thread 20260326-playground.md

1. **Localhost binding**. The proxy binds to `localhost` by default; remote network access is impossible without an explicit `--host` flag.
2. **Origin validation**. Browser requests from any `Origin` other than `localhost`, `127.0.0.1`, or `::1` are rejected, preventing malicious pages from making cross-origin requests to the local server.
3. **Session token authentication**. By default, `fga serve` generates a random session token at startup and prints it. All requests (except `/healthz`) must include the token via the `X-Serve-Token` header or `?token=` query parameter. The playground reads the token from the URL on first load, persists it in `sessionStorage`, and includes it in every subsequent request. A user-supplied token can be set with `--token <value>`, or token auth can be disabled entirely with `--no-token` (not recommended). This protects against other local processes (including malicious browser tabs not protected by the Origin check) using the configured server credentials.
Comment thread 20260326-playground.md

**`WASMBackendAdapter`**: Calls into a WebAssembly build of OpenFGA running in a Web Worker. The "server" lives entirely in the browser with no network calls. This adapter enables a fully hosted, shareable playground (e.g., `play.openfga.dev`) and an offline-capable experience. Deferred to a future iteration; gated on a WASM build of OpenFGA being available.

**`ProxyBackendAdapter`**: Calls `fga serve`, a local HTTP proxy that manages server profiles, stores secrets in `~/.config/fga/servers.yaml`, and forwards requests to upstream OpenFGA servers (local, Auth0 FGA, or any other). This enables local development with authenticated servers: it lets the user manage multiple server connections with their credentials in one place and avoids CORS issues by forwarding all requests server-side. It also avoids the issue with the DDirectBackend adapter of storing credentials in the browser. When `fga serve` has session token auth enabled (the default), the playground prompts the user for the token on first connection.
Comment thread 20260326-playground.md

- **Framework lock-in for consumers.** VS Code extension webviews are plain HTML/JavaScript contexts. React components cannot be used natively in them without bundling React into the webview's script. The same is true for any non-React documentation framework.
- **No native Web Component output.** React components are not Web Components. Embedding a React-based model editor in a Vue docs site or a plain HTML page requires wrapping it in an adapter, adding complexity for every consumer.
- **Version coupling.** Consumers of `@openfga/playground-components` would be forced to use a compatible React version. For Docusaurus that power our documentation site, it is usually tied to the React version Docusaurus needs, which would have the downstream effect of deciding what React version the Playground can support if we want to reuse it's components in the documentation. OpenFGA tooling should outlive individual React major versions; Lit's commitment to the browser standard avoids this problem.
Comment thread 20260326-playground.md

- This would make the playground unavailable to users who do not use VS Code.
- The Web Component approach delivers the same Monaco editor experience in any browser context.
- A VS Code extension is still a valid future consumer of the Web Components. It would embed `<openfga-model-editor>` in its webview, but building the components first gives us both possibiliities.
Comment thread 20260326-playground.md
- Import from and export to the store yaml file.
- Be able to connect to and switch between multiple stores.

While we have been pushing folks to use VSCode with the OpenFGA extension in combination with the CLI, the demand for a Playground has not subsided. Users have cited the model graph in particular as an asset when learning the OpenFGA authorization model or explaining the model to coworkers.
Comment thread 20260326-playground.md

#### Deployment and self-hosting gaps

- [openfga/openfga#2503](https://github.com/openfga/openfga/issues/2503): Request for a flag to serve custom static playground content instead of assets bundled in the binary, enabling lightweight Docker images. (Implicitly addressed by this RFC: the playground is a standalone web app, hosted it however one likes, pointing at the API.)
Comment thread 20260326-playground.md

#### Sample store browser

A dropdown lists all sample stores from the `openfga/sample-stores` GitHub repository. Selecting a sample fetches its `.fga.yaml` file and loads the model, tuples, and assertions into the playground. Samples are fetched at runtime so the playground always reflects the latest samples without a rebuild. These should be view only, but are importable into a new store/exportable into yaml. They cannot do any queries on them before importing, though that may be possible in the future once we have the WasmBackend.
Comment thread 20260326-playground.md
- **Binary size.** Compiling the OpenFGA server to WASM produces a binary of 10–20 MB+. This is not acceptable for an initial page load, even with compression and lazy loading.
- **Implementation complexity.** OpenFGA uses a persistence layer (database) that must also be replaced with an in-memory WASM-compatible implementation. This is significant engineering work that goes beyond this RFC's scope.
- **Reduced need at v1.** A main part of the target audience (developers who want to manage OpenFGA stores, in prod or dev) already have a server. The `fga serve` approach serves them well today.
- **Architecture readiness.** The `BackendAdapter` interface is explicitly designed to accommodate a WASM adapter in the future. When a WASM build of OpenFGA is available, it can be wrapped as a `WasmBackendAdapter` and plugged in without changing any component or core code.
Comment thread 20260326-playground.md

- **Framework lock-in for consumers.** VS Code extension webviews are plain HTML/JavaScript contexts. React components cannot be used natively in them without bundling React into the webview's script. The same is true for any non-React documentation framework.
- **No native Web Component output.** React components are not Web Components. Embedding a React-based model editor in a Vue docs site or a plain HTML page requires wrapping it in an adapter, adding complexity for every consumer.
- **Version coupling.** Consumers of `@openfga/playground-components` would be forced to use a compatible React version. For Docusaurus that power our documentation site, it is usually tied to the React version Docusaurus needs, which would have the downstream effect of deciding what React version the Playground can support if we want to reuse it's components in the documentation. OpenFGA tooling should outlive individual React major versions; Lit's commitment to the browser standard avoids this problem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants