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

Support mixed operators with various direct assignments #113

Open
rhamzeh opened this issue Nov 27, 2023 · 1 comment
Open

Support mixed operators with various direct assignments #113

rhamzeh opened this issue Nov 27, 2023 · 1 comment
Labels
discussion enhancement New feature or request

Comments

@rhamzeh
Copy link
Member

rhamzeh commented Nov 27, 2023

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 #16

@rhamzeh rhamzeh added enhancement New feature or request discussion labels Nov 27, 2023
@rhamzeh
Copy link
Member Author

rhamzeh commented Nov 27, 2023

At the moment, I am leaning for a combination of B and C (aka allowing both), on display we can always display C to ensure it is not confusing for people reading the DSL.

A is repetitive and possibly error prone
D can be confusing and needs changes to the JSON to be implemented properly

Note: We should make sure both this and self are reserved words in the DSL and in the JSON validation

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

No branches or pull requests

1 participant