Open FGA Wildcard Relationship From Object to User

311 Views Asked by At

I am trying to define user and admin schema in OpenFga

model
  schema 1.1
type user
  relations
    define admin: [admin#member]
type admin
  relations
    define member: [user]

I have added relationship where I have a user to admin relationship

User     admin:identity_admin
Relation admin
Object   user:rahul

I want to add a relationship wher all future user's admin should be admin:identity_admin. Something like

User     admin:identity_admin
Relation admin
Object   user:*

But seems like this is not supported by OpenFGA or I may be missing something. Any help will be appriciated

Open FGA Playground Link: https://play.fga.dev/sandbox

1

There are 1 best solutions below

0
Maria Ines Parnisari On

Model:

model
  schema 1.1
type user
  
type admin
  relations
    define admin_by: [user, user:*]

Then write this tuple:

USER: user:*
RELATION: admin_by
OBJECT: admin:identity_admin

Then calls of the form is user:X related to admin:identity_admin as admin_by? will be true for any X.