Replies: 3 comments 2 replies
-
Hi @jbolanosg If your data does not change frequently are you are OK with a delay between the moment the data is updated in the central OpenFGA server until it's available in all OpenFGA nodes, that can work. However, the solution will have more moving parts if you just call OpenFGA directly. I'd only take that path if the latency you get from a remote call is really not acceptable for you. Simpler solutions usually work better, and most OpenFGA customers are usually OK with the additional latency. If you the amount of data is not large and does not change much, latency should be pretty low. An approach you can try, instead of refreshing tuples periodically, is to have each OpenFGA server in a sidecar using the /changes endpoint to retrieve the tuples that were modified, and write them locally. This will be more efficient than reading all tuples. If the amount of data is not big, you can bootstrap your OpenFGA sidecars by reading the authorization model from the server, writing it to the local OpenFGA, and then use /changes to get all the data. If you end up giving this approach a try let us know. We are not aware of anyone doing it, but it can be useful with low data volume and low change frequency. |
Beta Was this translation helpful? Give feedback.
-
Can you expand why a central database would make the implementation more difficult? You still need to have maintain one for synchronizing from KeyCloak, correct? The difference would be making a call to the sidecar vs making a call to the central server. You can learn about the changes endpoint here https://openfga.dev/api/service#/Relationship%20Tuples/ReadChanges, or here https://openfga.dev/docs/interacting/read-tuple-changes If you use the |
Beta Was this translation helpful? Give feedback.
-
Hi Jorge, Thanks for the explanation, I understand the rationale now. I think that creating a service thats reads from the central OpenFGA service and reads to the local one using the If you want to further discuss the scenario feel free to add me in Linkedin (it's in my Github profile) and we can have a quick call in Spanish :) Regards, Andres |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I want to use OpenFGA for authorization in a new Next.js project running on Kubernetes. I plan to configure OpenFGA as a sidecar to my application to reduce latency. For this, I'm thinking of creating a custom Docker image based on the official OpenFGA image and adding the following steps:
Install SQLite inside the container.
Install the OpenFGA CLI.
Create a shell script that does the following:
a. Connect to a GitLab repository (URL provided through an environment variable) to fetch the latest version of the model to use in OpenFGA (model.fga) and default tuples to initialize (tuples.json).
b. Create the SQLite database (or drop and recreate it if it already exists).
c. Start OpenFGA with:
nginx
Copiar
Editar
openfga migrate --datastore-engine sqlite --datastore-uri 'file:/path/to/openfga.db'
openfga run --datastore-engine sqlite --datastore-uri 'file:/path/to/openfga.db'
d. Use the OpenFGA CLI to complete the configuration:
pgsql
Copiar
Editar
fga store create --model model.fga # using the model from GitLab
for each tuple in tuples.json:
fga tuple write <<tuple_content>>
e. Retrieve from an environment variable the URL of an API that returns additional tuples (role-to-org, user-to-role relationships). Use the Node.js SDK to insert these tuples into OpenFGA. This step is meant to emulate the behavior of OPAL_DATA_CONFIG_SOURCES in OPAL Server. See: https://docs.opal.ac/getting-started/running-opal/run-opal-server/data-sources
f. Implement a polling logic (similar to OPAL_POLICY_REPO_POLLING_INTERVAL) to periodically refresh the model and default tuples from GitLab. After fetching, compare with previous versions and apply changes to the OpenFGA server using the Node.js SDK.
g. Similarly, implement polling for the external API (step e), compare results with previous data, and apply differences to the OpenFGA server.
For data updates, in my particular case, we plan to use Keycloak as the IAM and will rely on the extension at:
👉 https://github.com/embesozzi/keycloak-openfga-event-publisher
The goal is to start OpenFGA with fresh model + tuple data, and allow frequent updates using the strategies described above—similar to how OPAL Server + Client operate, but using SQLite internally within the pod. This way, we achieve millisecond-level authorization checks, no need for a centralized database, and no external dependencies.
If this works, we could implement a sidecar OpenFGA server with only internal SQLite that refreshes itself periodically via GitLab and an external API linked to Keycloak—effectively serving as a GitOps-style self-updating sidecar.
Do you see this as viable? Are there any performance or security risks with this kind of implementation?
I’m asking because it seems logical and could be a powerful, dependency-free solution—having OpenFGA run as a sidecar with optimal performance.
I'm new to OpenFGA, but I really like the project and its authorization modeling approach. I'm seriously considering replacing our initial plan using Permit.io (GitOps-based approach with OPAL Server + Client) with this solution. If the above works, it would greatly reduce complexity.
Thanks in advance to the OpenFGA experts for your insights. If this sounds feasible, I’d love to move forward with creating this custom image.
Beta Was this translation helpful? Give feedback.
All reactions