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

feat: support nested userset rewrite operands in the DSL #16

Closed
jon-whit opened this issue Aug 1, 2022 · 2 comments · Fixed by #107
Closed

feat: support nested userset rewrite operands in the DSL #16

jon-whit opened this issue Aug 1, 2022 · 2 comments · Fixed by #107
Labels
enhancement New feature or request

Comments

@jon-whit
Copy link
Member

jon-whit commented Aug 1, 2022

The DSL today does not support nested userset rewrite operands and/or compound expressions delineated by parenthetical expressions. The DSL language should be extended to support compound expressions with parenthetical expressions so that it supports the same expressiveness of the JSON support existing today.

Below are some examples of the unsupported functionality.

# sample1
type document
  relations
    define restricted as self
    define editor as self
    define viewer as editor or (self but not restricted)
# sample2
type document
  relations
    define restricted as self
    define parent as self
    define editor as self
    define (viewer but not restricted) or (editor and viewer from parent)

These same models are supported in the JSON structure today, for example:

# sample 1
{
  "type_definitions": [
    {
      "type": "document",
      "relations": {
        "restricted": { "this": {} },
        "editor": { "this": {} },
        "viewer": {
          "union": {
            "child": [
              { "computedUserset": { "object": "", "relation": "editor" } },
              {
                "union": {
                    "child": [
                        { "this": {} },
                        {
                            "difference": {
                                "base": {
                                    "this": {} 
                                },
                                "subtract": {
                                    "object": "",
                                    "relation": "restricted"
                                }
                            }
                        }
                    ]
                }
              }
            ]
          }
        }
      }
    }
  ]
}
# sample2
{
  "type_definitions": [
    {
      "type": "document",
      "relations": {
        "parent": { "this": {} },
        "restricted": { "this": {} },
        "editor": { "this": {} },
        "viewer": {
          "union": {
            "child": [
              {
                "difference": {
                    "base": {
                        "this": {} 
                    },
                    "subtract": {
                        "object": "",
                        "relation": "restricted"
                    }
                }
              },
              {
                "intersection": {
                    "child": [
                        {
                            "computedUserset": {
                                "object": "",
                                "relation": "editor"
                            }
                        },
                        {
                            "tupleToUserset": {
                                "tupleset": {
                                    "object": "",
                                    "relation": "parent"
                                },
                                "computedUserset": {
                                    "object": "",
                                    "relation": "viewer"
                                }
                            }
                        }
                    ]
                }
              }
            ]
          }
        }
      }
    }
  ]
}
@jon-whit jon-whit added the enhancement New feature or request label Aug 1, 2022
@rhamzeh rhamzeh transferred this issue from openfga/frontend-utils Jul 31, 2023
@smaddock
Copy link

smaddock commented Oct 3, 2023

This Discord discussion provides another example of what's possible in JSON but not DSL today, and a possible workaround by @rhamzeh: https://discord.com/channels/759188666072825867/1158499973479022632

@seandlg
Copy link

seandlg commented Nov 8, 2023

This is something that we're very interested in, too.

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

Successfully merging a pull request may close this issue.

3 participants