Hi all,
I want to create a group can inherit permissions from other group.
Ex:
developer
---- backend
---- frontend
Expected:
- “developer” group have permission: sessions.add_session
- “backend: group have permission: sessions.delete_session
→ the user:” dev1" in “backend” group have 2 permisson: sessions.delete_session, sessions.add_session.
I tried:
- Add parent filed in to group:
Group.add_to_class('parent', models.ForeignKey('self', null=True,
blank=True, on_delete=models.SET_NULL, related_name='children'))
- Create group: “developer” and “backend”. “developer” is parent of “backend”
- Create “backend_dev1” user and set it into group “backend”
When I login “backend_dev1”, it only have permission of “backend” group.
I also tried use signals to set permissions after create user, but it not work.
Even if it worked, it would be difficult to update permissions when parent groups have permission changes.
of course, I can set user have 2 group: ‘developer’ and ‘backend’.
But I’m looking for solution can auto inherit permissions from other group.
I hope to have some suggestions on this topic.
Many thanks !