Spin-up an ephemeral docker instance.
docker pull openfga/openfga && docker run -p 8080:8080 -p 8081:8081 -p 3000:3000 openfga/openfga run
In another terminal, create a store.
fga store create --name "FGA Demo Store"
Make note of your store ID for use in following commands, for example:
export STORE_ID=01J7MBWN53GQ7PD1JKFEBE83NQ
Write the model.
fga --store-id=$STORE_ID model write --file model.fga
Write a tuple for jack
.
fga tuple write --store-id=$STORE_ID user:jack owner document:foobar
And perform some checks for jack
, noting that because he is an owner
he's also a writer
and editor
.
fga query check --store-id=$STORE_ID user:jack owner document:foobar
fga query check --store-id=$STORE_ID user:jack writer document:foobar
fga query check --store-id=$STORE_ID user:jack reader document:foobar
Write a tuple for jane
.
fga tuple write --store-id=$STORE_ID user:jane reader document:foobar
And perform some checks, noting that she's only a reader
.
fga query check --store-id=$STORE_ID user:jane owner document:foobar
fga query check --store-id=$STORE_ID user:jane writer document:foobar
fga query check --store-id=$STORE_ID user:jane reader document:foobar