grav-plugin-login icon indicating copy to clipboard operation
grav-plugin-login copied to clipboard

Permission on folders.

Open hifall opened this issue 8 years ago • 3 comments

Is it possible to define an ACL rule on a folder, and have all pages inside that folder to inherit the permissions by default, unless explicitly specified otherwise? This way, one doesn't have to specify the same rule for all the pages in the folder.

Note this is different from the "Use parent access rules" feature in the plugin's description.

Thanks.

hifall avatar Oct 29 '17 04:10 hifall

So what your asking for is an option you can set on a parent page, like children_use_same_acl: true and then you don't have to add any access attributes on those child pages, the page would first check if access rules exist, then navigate up until it found an access rule, and perhaps this option enabled, and if true, use that found page's access rules?

rhukster avatar Oct 30 '17 22:10 rhukster

Yes, you are right. That would be one of the possible options from an implementation perspective :)

As in a user scenario, one can use this feature to set up a private portion of documentation easier than otherwise. For example, suppose our documentation goal is to set up "FAQ" and "Internal" parts, with FAQ being public and containing 50 articles, and Internal being private and containing 200 articles, we can simply create 1 directory for each, then drop the 50 articles into FAQ and 200 into Internal, and set up the appropriate ACL rule for each folder. Then whenever we want to toggle the publicity of a document, we don't have to touch the frontmatter of the document to change the ACL rule, we simply move it to the proper directory instead.

And if any of the pages in a directory has its own ACL rules, these rules will override any parent ACL rules if defined.

It's pretty much like how we use a "protected" folder in an operating system: if we want to protect a number of files with password, normally what we do is to make a folder, move the files into the folder, protect the folder, then all the files in the folder becomes protected automatically. Any file going into the folder becomes protected, and vice versa.

For such a user scenario, this would be cleaner and more intuitive, IMHO.

hifall avatar Oct 30 '17 23:10 hifall

Ok, because that is basically what the parent_acl option does when you set it at the global plugin level. Have you tried it? Looking at the code it should work as you describe.

rhukster avatar Oct 31 '17 00:10 rhukster