Component level access control based on roles #937
Replies: 3 comments 6 replies
-
Super write up actually, I think you covered pretty much all the points we discussed. This per-component system solves all the following use cases (and lots of others) without any duplication of screens:
Basically I think this is a well thought out method that will solve every use case I can think of, without duplication. As described roughly above, I have ideas for how to make the UI for this as simple as possible as I think it's very important to get right. I'll talk through more of the UI ideas in the review meeting this Friday. |
Beta Was this translation helpful? Give feedback.
-
I like that we can cover these use cases, and trust that you can do it in a user-friendly manner. I do have a few points.
Who's level is "higher" here?
|
Beta Was this translation helpful? Give feedback.
-
Would love to be able to have Layouts have conditional Links based on Role. |
Beta Was this translation helpful? Give feedback.
-
Currently the builder has the ability to control access to screens (and therefore layouts) via a role hierarchy. Each user has a specific role level and they will have access to a set of screens based on this, e.g. a basic user can see all basic and public screens while a power user can see power, basic and public screens and so on. There are some extensions we think could be made to this which will simplify creating apps with lots of different user levels.
One of the major problems the current system faces is that if you want to have save a different nav bar for each role level you need to create a different layout for each role level and then pick the correct one based on the logged in user level - this is confusing and difficult to achieve. Instead it would be better if the links in the nav bar itself were controlled by role as well, so the links to the screens a user has access to it will only appear and any link they do not have access to with not be shown. To do this we need role control for components.
Me and @aptkingston had some ideas around this and I wanted to put them up here for discussion.
This is an extension of the existing system for roles that manages screens to allow children of screens and layouts to be managed with a role as well.
There are a few parts to this that are required for it to work correctly.
The option to control a screen/component with a role should have a choice, either to allow roles that inherit the selected role to view it as well or to set it so that only a particular role can actually view the component. Only allowing one role to view a component could be useful for something like a welcome message, e.g. "Welcome to the Admin interface" or "Click here to do power user thing" which may not be applicable to a role with a higher level role, giving the user the option to select the method by which the component can be viewed will give the user both options. By default all components should default to the hierarchy method and then the user can disable this with a checkbox is required, something like "allow/dis-allow roles that inherit access"
The API needs to be extended to strip out components from client definition and builder definition calls, as well as doing this on layout and screen get calls. Currently this is done on all the calls that manage screens, layouts are not currently covered by roles in anyway as they are linked to my a screen so they implicitly gain a role level through the screens that link to them. When retrieving these definitions the server should iterate through all the children and strip out any definitions which are not viewable based on a specified role level. In the client definition call this will be the role of the user that is currently logged in.
The builder definition calls should do something similar to what point 2 suggests, but instead of stripping out the children/screens it should add a prop like
visible: true|false
to each screen/component so that the preview can be rendered by stripping out the invisible components and screens. The role used to decide this should be passed in as a parameter to the fetch API.Continuing from the previous point, the visibility is necessary so that in the component tree we can show all the components that are on a screen but say whether they are visible or not for the current role. This removes the confusion of the tree components changing drastically each time the role is changed, instead some will simply be greyed out or marked invisible. We don't need to state why they are invisible, simply that the current role does not have the ability to view them.
Ideally all role logic should be maintained within the server and keep this out of the builder or client library, as this is the most secure method making sure a user never has access to content that their role does not allow them to view.
Each time the role is changed in the builder UI the API call would be made with the new role for the server to fetch the definition and work out what components should be viewable and which ones shouldn't be. If required we can do something around caching in this area to speed up the responsiveness of these calls for large screens.
Auto-links will likely require some updates for this to be really useful, the ideas around this would be that when autolinks are being filled out we attach the same role levels to the link itself based on the screens levels, take the list of screens on a route and select the lowest access level, use this for the nav link. When deleting a screen we need to check if any screens still exist on the route and if they do not delete the link (this is a QoL feature but want to document it here too).
Beta Was this translation helpful? Give feedback.
All reactions