openfga / openfga/language

Support mixed operators with various direct assignments

Open
#113 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discussion enhancement
Dominant language
Go
Stars
35
Forks
17
Avg merge
48m
Merged PRs (30d)
10

Description

We had split supporting the following JSON from #16 to reduce scope as this still needed discussion.

As a suggestion, consider the following three cases:

I-

"relation": {
  "union": {
    "child": [
      {
        "computedUserset": {
          "relation": "rel3"
        }
      },
      {
        "difference": {
          "base": {
            "intersection": {
              "child": [
                {
                  "computedUserset": {
                    "relation": "rel1"
                  }
                },
                {
                  "computedUserset": {
                    "relation": "rel2"
                  }
                }
              ]
            }
          },
          "subtract": {
            "this": {}
          }
        }
      }
    ]
  }
}

II-

"relation": {
  "union": {
    "child": [
      {
        "intersection": {
          "child": [
            {
              "this": {}
            },
            {
              "computedUserset": {
                "relation": "allowed"
              }
            }
          ]
        }
      },
      {
        "difference": {
          "base": {
            "this": {}
          },
          "subtract": {
            "computedUserset": {
              "relation": "blocked"
            }
          }
        }
      }
    ]
  }
}

III-

"relation": {
  "difference": {
    "computedUserset": {
      "relation": "rel1"
    },
    "subtract": {
      "this": {}
    }
  }
}

Note: We should consider rejecting this case (define relation: rel1 but not [user]) as it is nonsensical

Some potential solutions:
A. Allow restating the full type restrictions:
e.g.

  • define relation: rel3 or ((rel1 and rel2) but not [user])
  • define relation: ([user] and allowed) or ([user] but not blocked)
  • define relation: rel1 but not [user]

B. Allow using self
e.g.

  • define relation: [user] | rel3 or ((rel1 and rel2) but not self)
  • define relation: [user] | (self and allowed) or (self but not blocked)
  • define relation: [user] | rel1 but not self

C. Allow using self but require defining it for clarity (we can also have the define as optional)
e.g.

  • define relation: [user] as self | rel3 or ((rel1 and rel2) but not self)
  • define relation: [user] as self | (self and allowed) or (self but not blocked)
  • define relation: [user] as self | rel1 but not self

D. Allow defining an using an arbitrary name in lieu of self (needs an extension to the json to support it)
e.g.

  • define relation: [user] as some_name | rel3 or ((rel1 and rel2) but not some_name)
  • define relation: [user] as some_name | (some_name and allowed) or (some_name but not blocked)
  • define relation: [user] as some_name | rel1 but not some_name

Other questions to consider, does | as a separator make sense?

For other ideas, please post in the comments

Ref: Follow-up on https://github.com/openfga/language/issues/16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the follow-up context in issue #16 and the three JSON examples in this issue. The proposal still presents multiple unresolved syntax designs and asks for discussion; done would require an agreed representation for mixed operators, including the treatment of direct assignments and self, followed by implementation and tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.