Access only user-specific or template-specific pages in panel …

Is it already possible to define user roles — for the panel — which define that a user, e.g. …

  1. name-of-student, may only access and edit/create pages in content/2_students/name-of-student/?

  2. student, may only access and edit/create all pages with template student and these pages’ children (their template would be projects)?

Thinking of user permission in a linux/unix way where each user hast something like their “home” directory …

The permissions guide can be found here: https://getkirby.com/docs/guide/users/permissions

Thank you very much!

2 Likes

There is no explicit way to achieve this.

One solution a fellow Kirby user came up with was to create a separate blueprint folder per user role, but this solution has a lot of overhead.

Another way is to filter the accessible pages per user that are shown on the dashboard. Additionally you could then setup hooks to prevent access to the other pages.

I hope we will have more fine-grained permissions in an update, where you could define user roles with access in each blueprint.

Thank you, @texnixe.

I’ll see what I can come up with. And definitely …

I’m very looking forward to this update, heh.

I’d be interested in more granular user permissions as well. It would qualify Kirby 3 for sites with large editorial teams. The * wildcard approach should work well in most scenarios that I can think of.

There is probably already an issue in the ideas repo that you could upvote.

Edit: There are actually two:

1 Like

Hello, @texnixe!

I hope the update will come soon, it’s an extremly useful feature. Meanwhile, could you please share some insight into filtering pages on the dashboard per user in Kirby 3?

I’m trying to set up a site where certain users should have access only to the blog, depending on their role.
Then, each of these users should be allowed to edit their own articles only.

Thank you very much.

just my 2c… maybe panel views could be utilized to achieve something quickly? would it be possible to just wrap an existing blueprint in a panel view and check for permissions?
https://getkirby.com/docs/reference/plugins/extensions/panel-views

The option @gillesvauvarin came up with, was like this:

<?php

require __DIR__ . '/kirby/bootstrap.php';

$kirby = new Kirby();
$user  = $kirby->user();

if ($user && $user->role() == 'candidate') {
   $kirby = new Kirby([
       'roots' => [
           'blueprints' => __DIR__ . '/site/blueprints/candidate',
       ],
   ]);

} elseif ($user && $user->role() == 'sponsor') {
   $kirby = new Kirby([
       'roots' => [
           'blueprints' => __DIR__ . '/site/blueprints/sponsor',
       ],
   ]);
}

echo $kirby->render();

If combines a custom folder setup with a an if statement to check for the user roles and then returns a new Kirby object depending on that. Comes with a bit of overhead, but works.

2 Likes

Thank you, @bnomei. I’m not very familiar with Vue, though. But I’ll look into it.

Hello @texnixe. I’ve seen this post but found the solution a bit heavy. However I’ll give it a try. Thank you for pointing it out again!

Update: It’s working in my scenario, thanks.

is kirby able to use linked files (symlinks) for the blueprints or do they have to be actual files in the same folder?

1 Like

I’d like to know that, too :slight_smile:

I need to grant a group of users only access to edit a subpage (and all children). Is there a current workaround? It used to be able with hooks (page.read.before) but I don’t see this option anymore.

The hooks are still there: https://getkirby.com/docs/reference/plugins/extensions/hooks#available-events

but read:before never existed.

Better permissions are on the roadmap for 3.2

1 Like

Thanks,

I am using this exact setup but get this error:

Exception: TypeError
Argument 1 passed to Kirby\Cms\App::{closure}() must be an instance of Page, instance of 
Kirby\Cms\Page given

Any idea what might cause this error?

Probably because you’re in a namespace?

I don’t know what you mean, but I already fixed it.

(Page $page)

has to be

($page)

Was that in a plugin where you used the code? It should work in the config.

No I was using this in my general config.php (Kirby 3.1.3)

I am running two plugins: kirby-builder and kirby-color. Not sure if it can be connected to that

Hm, I tested in my 3.1.3 Starterkit and can’t reproduce the error. So I’m not sure if I should fix the docs or not.