Skip to content

[PoC] Implement parser for permissions framework#519

Draft
gpaoloni wants to merge 9 commits intomasterfrom
gian_CHI-2362
Draft

[PoC] Implement parser for permissions framework#519
gpaoloni wants to merge 9 commits intomasterfrom
gian_CHI-2362

Conversation

@gpaoloni
Copy link
Collaborator

@gpaoloni gpaoloni commented Dec 15, 2023

Description

This PR proposes a different approach to #520.
Here, I exemplify how we might use parser combinators to parse the expressions and map them to functions. This functions are in turn evaluated against user and target for each action as usual.

The advantage of moving to an approach like this is that we can simplify the expressions in the permissions frameworks with and with relatively little effort change from expressions like
"editContact": [["isSupervisor"], ["isOwner", { "createdHoursAgo": 24 }]]
to an analogous like
"editContact": "isSupervisor OR (isOwner AND createdHoursAgo(24))".

NOTES:

  • This PR does not means that we want/should remove the way we are currently evaluating the JSON-represented permissions rules. Instead, we could combine both approaches to use a more human readable DSL that is parsed and converted into the JSON-represented permissions rules.
  • This approach makes it easier to "validate" a JSON definition file IMO, as the rules for what is valid in the language are embedded in the parser, i.e. if a file parses then it's valid.

@gpaoloni gpaoloni changed the title Gian chi 2362 [PoC] Implement parser for permissions framework Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant