lablup / backend.ai

Backend.AI is a streamlined, container-based computing cluster platform that hosts popular computing/ML frameworks and diverse programming languages, with pluggable heterogeneous accelerator support including CUDA GPU, ROCm GPU, TPU, IPU and other NPUs.
https://www.backend.ai
GNU Lesser General Public License v3.0
517 stars 153 forks source link

Implement vfolder-host access control #753

Open achimnol opened 2 years ago

achimnol commented 2 years ago

There are some user scenarios that admins want to allow a specific project X members to mount read-only vfolders from the vfolder host A while they can freely create/use vfolders in the vfolder host B—and they want to prohibit the project X member's vfolder creation on the vfolder host A at the same time.

Currently, we only have the per-vfolder access control table (vfolder_permissions) and the access permission to vfolder hosts as a simple boolean set (merged from domains, groups, and keypair_resource_policies). As such, it is impossible to define a "read-only" permission to a specific vfolder host like that users may mount vfolders in the host but may not create new vfolders there.

The problem

Since we have allowed_vfolder_hosts defined in 3 different objects (domains, groups, and keypair_resource_policies), we need to first define how to merge them when each object has different properties like below:

domains("domainA").vfolder_host_permissions = {"storge1": {"access": "rw"}}
groups("groupX").vfolder_host_permissions = {"storage1": {"access": "ro"}}
keypair_resource_policies("researchers").vfolder_host_permissions = {"storage1": {"access": "rw"}}
# or
domains("domainA").vfolder_host_permissions = {"storage1": {"access": "ro"}}
groups("groupX").vfolder_host_permissions = {"storage1": {"access": "rw"}}
keypair_resource_policies("researchers").vfolder_host_permissions = {"storage1": {"access": "rw"}}
# or, when the user belongs to both groupX and groupY
groups("groupX").vfolder_host_permissions = {"storage1": {"access": "ro"}}
groups("groupY").vfolder_host_permissions = {"storage1": {"access": "rw"}}
keypair_resource_policies("researchers").vfolder_host_permissions = {"storage1": {"access": "ro"}}

In the above cases, should what access permission be applied?

Even if we extend the problem scope to a generic RBAC, the same issue arises with multiple subjects sharing the same target object and allowed action lists.

Design (2022/09/30)

ACL checks will be done in the server-side, while the configuration APIs should be exposed to the control panel and webui.

Follow-ups

achimnol commented 2 years ago

One idea by @fregataa:

achimnol commented 2 years ago

Another way is to split the permission level ("ro" or "rw") into fine-grained set of 'atomic' actions like generic RBAC and merge them by taking the union sets:

domains("domainA").vfolder_host_permissions = {"storge1": ["mount"]}
groups("groupX").vfolder_host_permissions = {"storage1": ["mount", "create-vfolder"]}
keypair_resource_policies("researchers").vfolder_host_permissions = {"storage1": ["mount", "create-vfolder", "delete-vfolder"]}
-> merged result: {"storage1": ["mount", "create-vfolder", "delete-vfolder"]}

domains("domainA").vfolder_host_permissions = {"storge1": ["mount", "create-vfolder"]}
groups("groupX").vfolder_host_permissions = {"storage1": ["mount"]}
keypair_resource_policies("researchers").vfolder_host_permissions = {}
-> merged result: {"storage1": ["mount", "create-vfolder"]}

In this case, it is no longer needed to store these information as columns of existing object entities but as a separate RBAC table for improved caching.

achimnol commented 2 years ago

Here is a good discussion about RBAC and ReBAC, with the "role explosion" issue, presented in PyCon KR (Korean): https://youtu.be/DXf_rQtpLZQ

Things to think about:

In this PR's design, we don't have a separate "role" property of an ACL entry but the subject itself may have a collective persona/identity (e.g., a domain applies to all of its users) and the caller of rule checker should provide the full list of multiple, contextual personas.