Replies: 2 comments 1 reply
|
Proposal: a capability layer, with read-only as its first use Thanks for opening this, Nicolas. Thinking it through made me question something underneath it: what can a user without roles do today, and is that set on purpose? From the ACLs on So before adding a read-only role, I'd like to make these rights explicit. Then read-only becomes one case of a general mechanism. The idea: ACLs scope, roles grantToday an ACL answers two questions at once: which objects a user may touch (their account's), and what they may do with them (all four verbs, for anyone in the account). I propose splitting these:
"trigger-schedules": [
(f"account:{self.account_id}", "cap:trigger-schedules"),
(f"account:{self.owner.consultancy_account_id}", f"role:{CONSULTANT_ROLE}", "cap:trigger-schedules"),
]A new Proposed capabilitiesAbout a dozen, named after what users do, not after endpoints:
Proposed predefined roles
Deleting: members can delete what is emptyDeleting a sensor cascades to all its beliefs and annotations, and deleting an asset cascades to its whole subtree. So "members may delete what they may create" would really mean "members may delete data". Instead:
This ends the copy-but-not-delete asymmetry, because copies carry no data. It also makes an ownership rule unnecessary: deleting a colleague's empty asset does about as much harm as editing it, which members can already do. "Is it empty?" depends on the object's state, not on who the user is, so I'd check it in One gap to fix along the way: an asset's deletion is logged on that asset's own audit log, and Backwards compatibility
Why not a restrictive role (option 1)?It would work, and it's less code. But it adds the first rule that takes rights away, so "why can X do Y?" can no longer be answered by finding a grant. It also leaves the implicit member rights undocumented. With capabilities, read-only is simply the role with the fewest of them, and the model stays additive. Option 2 doesn't need to be breaking either, if existing users are grandfathered into Admin-defined rolesOnce roles are bundles stored in Open questions
References
|
|
I like the direction and will start playing with it. One caveat: I see no need for the term "capabilities". As I udnerstand this, we are expanding the power of "permissions", as also Flask-Security calls them. Modeling permissions on the
Here is another question: Role grants are global, even when ACL scope is local. In (account:…, role:consultant, cap:…), the capability can come from another role the user holds. A consultant’s member grants may therefore work in client accounts; consultant capabilities may also work in their own account. Decide explicitly whether that combination is intended. If rights must differ by client account, global Role.permissions needs account-scoped role bindings. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I want to muse about enabling read-only demo accounts. A user who can not make any changed, just view data.
For this, one needs to know how Flexmeasures handles authorization with the
__acl__attribute - it is basically a system, where anything you get as a user (your account membership, consultancy relationships, user roles, ..) adds more access (gaining permissions on objects like assets, sensros, etc).Here, we look at three ways this could work. The favourite is to add a restricitve
read-onlyrole for users - a role that works different than other roles.A preamble about users without any roles - they can do the following actions in their account (non-exhaustive):
Certain things are not possible for them, e.g. creating assets, linking consultancy accounts, etc.
This separation makes some sense, assuming that anybody with a user accoun has rights to do limimted things, and we'll see in the audit log that they did so.
It might not be perfect, but we can adjust later.
My current goal is to be able to offer user accounts who can only read. Imagine a demo asset with data, for which I give outsiders the credentials of a demo user who can browse.
What is the best architectural approach for this?
I'm looking for something that keeps the auth modeling straightforward, but also keeps our code changes low.
1st approach: read-only restrictive role
Easy implementatiom: Existing
readgrants work as they do now, but non-readpermissions are centrally vetoed incheck_access()2nd approach: Having no roles = reader
This would mean that a pure user without roles can do nothing (see above on what they can do now). The only thing left is to read things in their account. This is conceptually cleaner, but it is a breaking authorization migration.
3rd approach: Users with no actual account (just "visitors")
They get as account a specific "External Users" account (which should own no assets, obviously), and be assigned to accounts viia a
visitorrelationship to get any access. This also seems like a large migration. It would be conceptually in line with being a purely additive role system, and good if we ever want any visitors to be able to read in more than one account.So to summarize, there are ideas, but I vote to take the simpler route, which is the first option. It is rather easy for everyone to see why someone cannot do something ("they have a read-only role") and the implementation is straightforward. FlexMeasures should not become complex at a faster rate than needed. Am migration from option 1 to one of the others seems pretty straightforward to me, as well.
Let me know if there are ideas or opinions.
All reactions