lemmy
lemmy copied to clipboard
Roles & fine-grained permissions
Requirements
- [X] Is this a feature request? For questions or discussions use https://lemmy.ml/c/lemmy_support
- [X] Did you check to see if this issue already exists?
- [X] Is this only a feature request? Do not put multiple feature requests in one issue.
- [X] Is this a backend issue? Use the lemmy-ui repo for UI / frontend issues.
Is your proposal related to a problem?
- https://github.com/LemmyNet/lemmy/issues/2976 currently has to be solved by allowing every admin the right to delete pretty much all content on an instance, which is not ideal;
- It's currently not possible to delegate certain admin functions to users (e.g. the ability to accept registrations) without also giving the users the ability to cause a lot of damage.
Describe the solution you'd like.
Design
There's a lot of changes in this PR, but the actually important changes are:
- adding a
site_role
table which has: an id, a name and a bunch of boolean permission flags for each individual admin operation (e.g.ban_person
,purge_comment
, etc.)- the actual specific flags I've added here are probably wrong and need a fair bit of finessing
- removing the
admin
column fromperson
- added
site_role_id
column toperson
- added two columns to
local_site
:-
top_admin_role_id
this references a role insite_role
and represents the super-admin role, i.e. it has all permissions -
default_site_role_id
this references a role insite_role
and represents a regular non-admin, i.e. it has no permissions
-
- on migrating, we create two
site_role
s which represent admins and non-admins and ensure any existing user with theadmin
flag gets assigned the admin role - wherever we were previously checking
admin
, we now check for a specific site permission
With these changes, we end up with a system that's functionally identical to the current one, just with a different underlying mechanism.
Enabled Features
It's fairly easy to imagine a UI letting anyone with the configure_roles
permission add and modify these roles and then assign them to users on their instance. This would potentially go some way to lightening the administrative burden of running an instance, since functions like approving registrations (or even global community moderation) can be delegated to somewhat-but-not-completely-trusted users.
This role/permission system could potentially be extended to communities and mods as well, so specific moderation functions become specific permissions. Roles could be defined at the community level, or at the instance level?
For even further extension, this role/permission system could generically replace bans/mutes. If posting to communities/viewing communities became permissions, then a 'Banned' role could be created which isn't allowed to do these things and banning a user then becomes a matter of assigning them to a specific role.
Describe alternatives you've considered.
n/a
Additional context
Note: copied from https://github.com/LemmyNet/lemmy/pull/3303
I would like to extend this to roles for more people. For example, I would like a role that would allow people to upload gifs or videos. Or a role that would allow people to embed images. It would allow admins to better control their communities based on accumulated trust of their base, and help prevent things like trolling via NSFW/NSFL/CSAM uploads.