Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize OpenFGA with a predefined StoreID #1132

Open
ashok-an opened this issue Nov 7, 2023 · 13 comments
Open

Initialize OpenFGA with a predefined StoreID #1132

ashok-an opened this issue Nov 7, 2023 · 13 comments
Labels
enhancement New feature or request Stale

Comments

@ashok-an
Copy link

ashok-an commented Nov 7, 2023

Why?

Like seeding DB engines with predefined DBs, there is a need to start a openFGA with predefined storeIDs (any valid ULID)

What is expected?

Run OpenFGA container with a seeding StoreID, a store should get created with the given ULID and appropriate log message displayed for verification

@jon-whit
Copy link
Contributor

jon-whit commented Nov 7, 2023

@ashok-an could you provide some examples of shell commands demonstrating what the OpenFGA startup process would look like with this?

What would an ideal cli interface look like to achieve this?

@ashok-an
Copy link
Author

ashok-an commented Nov 8, 2023

@ashok-an could you provide some examples of shell commands demonstrating what the OpenFGA startup process would look like with this?

What would an ideal cli interface look like to achieve this?

For simplicity, how it looks today is:

❯ fga store create --name "store-A"
{
  "store": {
    "created_at":"2023-11-08T04:12:09.966412585Z",
    "id":"01HEPJ2TBDBZEAMEWSGMP95SZ9",
    "name":"store-A",
    "updated_at":"2023-11-08T04:12:09.966412585Z"
  }
}

❯ fga store create --name "store-A"
{
  "store": {
    "created_at":"2023-11-08T04:12:14.882152171Z",
    "id":"01HEPJ2Z52WP8RK2G5CDNJ4MW5",
    "name":"store-A",
    "updated_at":"2023-11-08T04:12:14.882152171Z"
  }
}

What I mean/look for is:

❯ fga store create --name "store-A"
{
  "store": {
    "created_at":"2023-11-08T04:12:09.966412585Z",
    "id":"01HEPJ2TBDBZEAMEWSGMP95SZ9",
    "name":"store-A",
    "updated_at":"2023-11-08T04:12:09.966412585Z"
  }
}

❯ fga store create --name "store-A"
{
  "store": {
    "created_at":"2023-11-08T04:12:14.882152171Z", // original creation timestamp
    "id":"01HEPJ2Z52WP8RK2G5CDNJ4MW5", // original ID - 01HEPJ2TBDBZEAMEWSGMP95SZ9
    "name":"store-A",
    "updated_at":"2023-11-08T04:12:14.882152171Z"
  }
}

@jon-whit
Copy link
Contributor

jon-whit commented Nov 8, 2023

@ashok-an I think you may have accidentally copy/pasted the same thing twice. The two examples (before/after) are identical.

What I may infer from what you're trying to do, just based on the description you have, is that it sounds like you want an idempotent CreateStore method that operates on a Store name (e.g. only a single store of a given name can exist in OpenFGA). Is that what you mean?

@ashok-an
Copy link
Author

ashok-an commented Nov 9, 2023 via email

Copy link

It appears this issue has been stale for at least 14 days 🗓️. If no action is taken the maintainer team may consider closing the issue. Please reach out if you need feedback or follow up actions from the maintainer team.

@github-actions github-actions bot added the Stale label Nov 30, 2023
@fsedano
Copy link

fsedano commented Dec 1, 2023

@jon-whit @ashok-an I updated an existing issue for this same use case:

#989

Thanks,

@github-actions github-actions bot removed the Stale label Dec 2, 2023
@rhamzeh rhamzeh added the enhancement New feature or request label Dec 6, 2023
Copy link

It appears this issue has been stale for at least 14 days 🗓️. If no action is taken the maintainer team may consider closing the issue. Please reach out if you need feedback or follow up actions from the maintainer team.

@github-actions github-actions bot added the Stale label Dec 22, 2023
@PatrickMunsey
Copy link

I just posted an issue in the cli repo openfga/cli#331 (comment) prior to coming accross this issue here.

Allowing store-id to be specified would be really benifitial in simplifying deployment configuration. The goal would be to have the entire openfga deployment and configuraiton being able to be achieved repeatably with pre defined values. Requiring randomly generated store-id that changes during each deployment to be used for cli connections is cumbersome as opposed to something like a db connection string.

Some examples of how the usage could look:
fga store import --file test-store.yaml --store-id 01HYHGP755KA1BQMBR568RVKKV
or
fga store create --name test-store --model test-model.fga --store-id 01HYHGP755KA1BQMBR568RVKKV

I foresee being able to specify model-id in a similar fation would go a long way as well.

@danielloader
Copy link

Yeah this would be quite useful, the alternative I've taken to is just using pg_dump and moving around a database instead and frankly it's not ideal.

For local dev/CI purposes being able to define the model id and the store id feel almost like a requirement for a docker compose stack.

@abdok96
Copy link

abdok96 commented Aug 17, 2024

This is very essential when using docker compose and setting up some init scripts.
There should be a way to determine the store id so that it can be passed as env variable to other services.

@lvieirajr
Copy link

+1 to being able to set static model and store ids

@c-thiel
Copy link

c-thiel commented Oct 7, 2024

+1 for this.

If we cannot set the store-id on store creation, then the store-id becomes dynamic state that needs to be stored.
This is super inconvenient for stateless docker or K8s setups.

Imagine a "migration" container that runs before the app and is supposed to set an auth model (schema) to openfga.

The first time it runs, it currently creates the store and gets a random ULID in return. It then has to pass this on to the application, for example via an emptyDir, which is already not nice.

The second time this container runs, it must determine which migration to apply next. As the container is stateless, it does not even know which stores exist. It has to paginate through all stores until the store name matches. If we could specify the store-id on creation, this wouldn't be required as the store-id becomes easy to manage static information.

@flex-seongbok
Copy link

How about making store name unique and search store by name?
I think what we need is reproducable and expectable environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Stale
Projects
None yet
Development

No branches or pull requests

10 participants