Can i use permission for the files section?

I’m using user permissions and it works really fine for update / forbid updating a page or subpages.

When i forbid updating by a user its still possible to upload and delete files at this page. So can i control the permissions on a files section as well?

It might be possible that you have to set this in a “role”. See https://getkirby.com/docs/guide/users/permissions for more info.

I have 2 different roles, admin and an editor who should be able to edit just one page. With the user role and permissions i can control if he is allowed to update an existing page or no. Thats fine and it works. But on a page where he is not allowed to edit anything he can deleted und upload files.

I try to forbid it but couldn’t find a way…

I see. Do you upload files to those files sections with a given file-template? Maybe you can set permission options in that file-template? See: https://getkirby.com/docs/guide/users/permissions#specific-permissions-in-page-file-user-or-site-options

It works, yes and no. I can prevent that a file can be deleted but not a new will upload or rename the file. I will play a bit around with https://getkirby.com/docs/guide/users/permissions#controlling-permissions-with-hooks controlling with hooks. But its not perfect

if there is a better way, would be really great.

Unpopular opinion: setting the update permission of a page to false should also prevent uploading/deleting files on this page.

For now, shouldn’t it be possible to set create: false in the file blueprint?

@ThomasLal I’m curious, since you have two roles and each can only edit one page, why don’t you simply prevent the access to the other page entirely?

Using…

  read:
    admin: true
    editor: false

…you can prevent the access to that specific template completely. The user won’t even see the page in the panel

cause i miss this option in my blueprints :man_facepalming: thank you!

There are options to control what a user can do with files in a files blueprint, so you can forbid deleting, updating, changing name and replacing, but looks like you can’t prevent uploading (I tried add, create, upload, none of these worked).

I think we need a feature request if it doesn’t exist yet.

2 Likes

You can also still sort the images in the section. I think the entire section should go in a “read only” mode if the update option is set to false.

Regarding file sorting, there is already this issue: https://github.com/getkirby/kirby/issues/1969

Once this is fixed, it should also be possible to prevent sorting on a per user role, I assume.

Nevertheless, I added a new issue:

2 Likes