Skip to content

Top level permission #4345

Description

@gareins

I want this simple permissions system: there is a group that can only make changes under FOO page, meaning the FOO page itself can not be edited, but subpages can be.

Other things I tried:

  • setting / path has -c+r-u-d permission with inheritance=true and then only the page where i do allow creation of chlidren i also set -c+r-u-d permission, but with inheritance=false. My logic is that the permission on pages api is taken as default, which is for this group is "allowed". This fails, only disables editing of home page (the page under '/') and the FOO page, everything else is editable
  • Next, I set the same -c+r-u-d permission with inheritance=true on all top level pages, but user can still create new top level pages (as well as complicated system that this creates),
  • setting only pages read api to the user group, but then no pages can be created, since the "new page" button does not exist without this permission
  • there is also this root.md documented under 1.7 admin panel, which I dont know the current state, but doesnt seem to prevent creating top level changes

Any ideas?

Activity

  1. rhukster commented on Oct 6, 2026

    @rhukster
    Member

    Thanks @gareins, this is a good test of the page permissions, and your attempts were close. Two things were getting in the way:

    1. The / route is the home page, so a rule on / only changed the home page. The "top level" is an invisible root page, and a regular (non-Flex) Grav 2.x site never read rules for it, so there was no way to say "nobody in this group may create top-level pages". That's now fixed: rules in user/pages/root.md apply to the top level, as they already did on Flex Pages sites. It will be in API plugin 1.0.45.
    2. A page rule covers the page and everything below it, so one rule on FOO can't say "FOO read-only, children editable". The trick that works is the authors entry: the "authors" pseudo-group is matched against the page being edited, not the page holding the rule.

    Setup that I tested (the group has api.access, api.pages.read and api.pages.write):

    user/pages/root.md, which denies create, update and delete by default for the group:

    ---
    permissions:
      groups:
        editors: '-c-u-d'
    ---

    FOO's page frontmatter (Page Permissions in the editor), where editors is your group and every member goes in authors:

    permissions:
      authors:
        - jane
        - bob
      groups:
        editors: '+c+u+d'
        authors: '-u-d'

    Result: members can create, edit and delete anything under FOO, cannot edit or delete FOO itself, cannot create top-level pages, cannot edit or delete other top-level pages, and can still read everything.

    Every member of the group has to be listed in FOO's authors, otherwise they can edit FOO. Until 1.0.45 is out, you can get the same effect over the API by dropping the group's api.pages.write (keep api.pages.read) and leaving the root file out, but then Admin2 hides the New Page button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions