Repository navigation
Conversation
…added admin controls
…o save Rulesets before the Role
|
Looks like you've been doing a lot of research here! I've spent some time playing around with your code, and experimenting myself. I think that this is becoming a lot more complicated than I first expected, which is fine, but means we'll need to consider this very carefully. Complex Permission RulesIt is not sufficient to match each "RuleSet" with an "app" e.g. Part. There will be interlinked permissions (e.g. the Build permissions will require part.bomitem permissions or stock.stocklocation) etc. Also what about models such as "PartStar" - this links a "starred" part to the given user. We should not require that a user be given permissions to create a PartStar object in the part_part_star table when they click the "star" button (for example). Role ModelI do not think that the one-to-one addition of the Adding a Overall ThoughtsCurrently the web interface and API do not implement the permissions system at all - it is only implemented in the admin interface. We do not necessarily have to add permissions requirements to every element of the system - we could add it on an "as-needed" basis to simplify the implementation. For example, the "part star" example as listed above. Secondly, there are probably some permissions that every user needs to have. Also, there will be many linked permissions as I suggested above. Do we "need" the fine-grained control that the default django permission system allows? Or can we hide this entirely, start with some coarse permissions, and increase fidelity as needed? I've also added some other thoughts inline with the code. Let me know what you think.. I feel we are on the right track, and I really like the simple grid interface, but not sure we're 100% there yet. |
|
For reference: #1018 |
Further ThoughtsPermissions FidelityAs the complexity of the "roles" increases, we get closer and closer to just using the default django permission fields. Not sure what my point is here, just thought it was worth noting. Even if all the "roles" implementation is doing is increasing readability so the user does not have to wade through entries like Permissions ConflictsLet's say some roles have overlapping permission on a given table, e.g. |
|
@SchrodingersGat Thanks for looking into this and creating that new PR, I will try to look into it soon and respond/comment on your thoughts. |
|
Following on from the fantastic work you've done here, I think #1018 provides a solution that I'm happy with. Let me know what you think! This PR does not actually do anything with the permissions yet - that will take some doing as we have to guard a lot of parts of the interface. But that can be an ongoing work in progress! For example, see #1011 |
I anticipated it would the case, I had left room for improving this part (as suggested in the TODO list, the models weren't finalized). Looks like you had it covered in #1018
I agree it adds a bit of complexity and you're more familiar with Django than I am so I'll follow your call on this one 😉
True, I was going to tackle this next, after defining and stabilizing the logic for the permissions.
I see that you've removed it in #1018, maybe we wanted to keep it for the time being, especially when developing templates and would be easier for testing (eg. quickly add and remove a model permission).
I agree with the net improvement, I think it's fair to consider users don't need to look at the source code to define permissions. Any great software cannot be without a user-friendly interface, InvenTree is on the path of joining that category so I think it's worth the effort!
That's a very good point, we should have the ability to drive this case-by-case and take the "safer" path but always good to keep in mind. |
|
Thanks for the great work here @eeintech 👍 |
This is an attempt to introduce
RolesandRuleSetsinto InvenTree's user authorization flow.Roles and RuleSets
What is a Role
A
Roleis mirroring the DjangoGroupmodel instead of extending it or creating a custom model.A Role has currently 5
RuleSetinstances automatically created and managed from the role perspective.What is a RuleSet
It is the standard set of Django permissions for model (eg. view, add, change, delete) except that each applies to a superset of models. Basically, the
RuleSettries to simplify the language for admin users and automatically matches an InvenTree "application" (eg. Parts, Stock, Build, etc.) to its corresponding set of models so that the user does not have to know which model to set permissions on.What is implemented so far
RoleandRuleSetmodels, along with a set of starter methods.Those models are located in the
usersapp.The roles can be created and managed inside the Admin interface, under
Users(very bottom of the index):To create a Role:
What about the Group model in all this?
Well, after the
Roleinstance is saved, all permissions related to all models from the rulesets are updated inside aGroupinstance of the same name as theRoleinstance (open the "Home › Authentication and Authorization › Groups" page and click on the role name you just created):What about users?
To add a role to a user, it's as simple as adding the corresponding group:
TODOs
RuleSetto better represent InvenTree applications (need your insight here @SchrodingersGat)RoleandRuleSetmodels