Implement multi-tenancy access controls: restrict users to specific areas of interest
I've read https://github.com/digitalocean/netbox/issues/446 and thought that it would be nice to have a more general and finer access control with an ability to restrict users (user groups) to view / edit / create objects only in specific Tenants, Tenant Groups, or Sites. And such access control should be enforced in UI as well as in API access.
That way one could give some limited access for the tenants' engineers themselves, or set some internal access boundaries (for the security-conscious).
One way to acheive this is per-object permissions, maybe based on Django-Rules (https://github.com/dfunckt/django-rules) or similar
I know this was mentioned on #323 but I'd like to add my voice. I just setup NetBox and found it is 100% what my org needs, however not having permissions at the site level is a deal breaker. With 30+ national sites we don't want to give everyone that needs to change IP prefixes at their site the ability to change prefixes across the country. Either way, awesome job Jeremy, this is an impressive and well thought out tool.
This would be (if I understood aright) a useful feature to allow IT sub teams the management e.g. of their own site(s)/IP space.
Hi all.
I also strongly support this feature. This is one of the most important feature since it is about cloisoning et security.
I'd love to bring this up again. I'm wanting to deploy NetBox within my organization, but a requirement from my higher ups is that there must be a way for our customers to see their components in our datacenter/network.
We too are planning to give our customers access to their own racks in our datacenter spaces. I'd very much like this feature to be implemented. As it is now, we'd have to run one netbox instance per customer. It would be great if it would be possible to give user account access to one or more tenants.
BTW, great job!
Implementing this would allow me to use Netbox to replace teampass along with IPAM and Racktables. I need to control access to secrets along side the devices they pertain to but I don't want other groups to have access to an secrets but their own.
Hey @jeremystretch I have a rough implementation of this feature but would like your opinion and some direction.
- I've added
UsertoTenantsas a ManyToMany, this was the easiest for me but I think it should be the other way Tenants to User. - Added a
filter_accessfunction to ModelManagers
class ObjectFilterQuerySet(models.QuerySet):
def build_args(self, user):
return models.Q(tenant__users__in=[user])
def filter_access(self, user):
if not user.is_superuser:
try:
return self.filter(
self.build_args(user)
)
except TypeError:
return self.none()
return self
- to Models: x Aggregate x Circuit x CircuitTermination x ConsolePort x ConsolePortTemplate x ConsoleServerPort x ConsoleServerPortTemplate x Device x DeviceBay x DeviceBayTemplate x DeviceRole x DeviceType x Interface x InterfaceConnection x InterfaceTemplate x InventoryItem x IPAddress x Platform x PowerOutlet x PowerOutletTemplate x PowerPort x PowerPortTemplate x Prefix x Provider x Rack x RackGroup x RackReservation x RackRole x Role x Service x Site x Tenant x TenantGroup x TopologyMap x VLAN x VLANGroup x VRF x ImageAttachment
- The modules with no reference to User or Tenant I've added a Tenant field like DeviceType
- Hide Tenant and TenantGroup from user in objects and selected the only available one in forms
- Created a Middleware to extract the user as a global object connected to the request
- Added
filter_accessto allget,postrequests and general querysets that I could find - Added tenants to
UserAdmin
I'd find this useful as well!
@icaro with the more generic models (like DeviceType), have you made the Tenant a Many-to-Many? There are cases where I'd like to grant access at the TenantGroup level. Have you given any thought to that? In my case I have:
TenantGroup: Business Unit A Tenants: Unit A Internal, Customer A.1, Customer A.2, Customer A.3 TenantGroup: Business Unit B Tenants: Unit B Internal, Customer B.1, Customer B.2, Customer B.3
(My ideal would be to have Tenants nestable and ignore TenantGroups...)
Hello @i1caro , do you still working on that? That is a very critical feature. I'd love to see it implemented. Right now I'm forced to keep a legacy system for a few prefixes that I need to give write access for internal teams. Just waiting for this feature to finally get rid of the legacy system.
@orgito @shugotek I'm afraid this feature would need some kind of sponsor. Something like a company paying someone to work on a mergable implementation.
FYI I won't accept any sponsorship or merge any sponsored work on the project. Anyone who wishes to do so will need to maintain their own fork.
I just meant if folks need this at work then maybe $WORK should have someone implementing this on company time.
And a company running this customer facing (sounds like @Schnatterowski's would) has more reason to maintain this code than one where it's just running internally for different departments ;)
FYI I won't accept any sponsorship or merge any sponsored work on the project. Anyone who wishes to do so will need to maintain their own fork.
Can you specify what a 'sponsorship' means in this context? When something is contributed in company time or when $company wants it's name/sponsorship included in some kind of 'wall-of-fame' somewhere?
FYI I won't accept any sponsorship or merge any sponsored work on the project. Anyone who wishes to do so will need to maintain their own fork.
I'm curious, why not?
I would assume that sponsorship means it is still planned, eventually, but won't ever be included as a paid addition.
I can understand that, as it introduces a slippery slope of "if I throw enough money at jstretch, he will do whatever I ask to Netbox right?"
This still has the "Accepted" and "Major Feature" tags, so unless those change, you can assume this is still a planned feature at some point.
I can understand that, as it introduces a slippery slope of "if I throw enough money at jstretch, he will do whatever I ask to Netbox right?"
Bingo. The maintainers only have so much time we can contribute to NetBox's development. Imagine if we had to choose between implementing a feature 80% of the user base wants, for free, or implementing some niche feature which would highly benefit one specific vendor, in exchange for $10K? I'm not even going to pretend: I'd take the $10K in a heartbeat. A ban on paid work prevents vendors from steering the direction of the product in their interest.
I can understand that, as it introduces a slippery slope of "if I throw enough money at jstretch, he will do whatever I ask to Netbox right?"
Bingo. The maintainers only have so much time we can contribute to NetBox's development. Imagine if we had to choose between implementing a feature 80% of the user base wants, for free, or implementing some niche feature which would highly benefit one specific vendor, in exchange for $10K? I'm not even going to pretend: I'd take the $10K in a heartbeat. A ban on paid work prevents vendors from steering the direction of the product in their interest.
If understood correctly a code contribution made during work hours ('paid for by the boss') doesn't count as a sponsorship then, right?
Hello @i1caro , have you done any progress so far? We are evaluating Netbox for device inventory in my company and this is something that would be very useful for us in order to correctly segregate the permissions between our teams.
@Tesshu Please don't ask for updates here.
Feature requests will get done when they get done.