RolifyCommunity / rolify

Role management library with resource scoping
https://rolifycommunity.github.io/rolify/
MIT License
3.16k stars 404 forks source link

can we define a hierarchy for the role lookup until it goes to global? #586

Open krtschmr opened 1 year ago

krtschmr commented 1 year ago

From reading the docs I understand we can define a user who has access to a document. If we check on the document if the user has access, we do check for a specific resource access if not, we fall back to global added role.

We do have a permission system where we define access on a Document or on the DocumentFolder or on the Global Level. So whenever we check access for a document, we must check resource access or via folder access or via global access

Is this something rolify can also handle (docs doesn't explain this). If not, can we achieve this with ease by configure something like

config.resource_access_lookup = {
  "Document"=> ["resource", "DocumentFolder", "global", ],
  "Template" => ["resource", "TemplateFolder", "UltraFolder", "EvenHigherFolderModel", "global" ]
}

Is our usecase even broad enough to make it worth a PR?

Currently we have a lot of customcode and by having rolify supporting our usecase we would like to actually use it and get rid of our pita code.