Support negative permissions constraints #11848

Open
opened 2025-12-29 21:50:39 +01:00 by adam · 3 comments
Owner

Originally created by @llamafilm on GitHub (Nov 19, 2025).

NetBox version

v4.4.6

Feature type

New functionality

Proposed functionality

I'd like to create permissions constraints with negations. The constraint JSON syntax would use the same lookup expressions which are already supported in the REST API, for example {"vrf_id__n": null}.

Use case

I've built a few automations to pull in data from external sources into Netbox. I don't want users to edit those objects because any changes may break the automation. One example is: Prefixes in the global VRF are imported from BloxOne DDI, so users should not be able to edit them. We have a number of air-gapped networks, which each use overlapping 192.168 address space. Each of those is modeled as a separate VRF in Netbox, and users should be able to manipulate those Prefixes freely. So I would like to create 2 separate permissions for Prefix editing, one with {"vrf_id": null} and the other with {"vrf_id__n": null}

Database changes

No response

External dependencies

No response

Originally created by @llamafilm on GitHub (Nov 19, 2025). ### NetBox version v4.4.6 ### Feature type New functionality ### Proposed functionality I'd like to create permissions constraints with negations. The constraint JSON syntax would use the same lookup expressions which are already supported in the REST API, for example `{"vrf_id__n": null}`. ### Use case I've built a few automations to pull in data from external sources into Netbox. I don't want users to edit those objects because any changes may break the automation. One example is: Prefixes in the global VRF are imported from BloxOne DDI, so users should not be able to edit them. We have a number of air-gapped networks, which each use overlapping 192.168 address space. Each of those is modeled as a separate VRF in Netbox, and users should be able to manipulate those Prefixes freely. So I would like to create 2 separate permissions for Prefix editing, one with `{"vrf_id": null}` and the other with `{"vrf_id__n": null}` ### Database changes _No response_ ### External dependencies _No response_
adam added the type: featurepending closurestatus: revisions needednetbox labels 2025-12-29 21:50:39 +01:00
Author
Owner

@jnovinger commented on GitHub (Nov 19, 2025):

Seems to be essentially the same request as #4949, which was closed as stale while under review. At the very least, we'd need to figure out if this is any more feasible now than it was in the past.

FWIW, the __n convention is a NetBox filterset convention. It is not something that is available at the ORM query construction level, like conventional Django ORM filters/lookups. That technical hurdle will need to be addressed if this is to move forward, since permission constraints are based on queryset operations.

@llamafilm, please update your FR with how you propose to achieve this. Otherwise, I don't believe this FR is actionable as it stands.

@jnovinger commented on GitHub (Nov 19, 2025): Seems to be essentially the same request as #4949, which was closed as stale while under review. At the very least, we'd need to figure out if this is any more feasible now than it was in the past. FWIW, the `__n` convention is a NetBox filterset convention. It is _**not**_ something that is available at the ORM query construction level, like conventional Django ORM filters/lookups. That technical hurdle will need to be addressed if this is to move forward, since permission constraints are based on queryset operations. @llamafilm, please update your FR with how you propose to achieve this. Otherwise, I don't believe this FR is actionable as it stands.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 27, 2025):

This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.

@github-actions[bot] commented on GitHub (Nov 27, 2025): This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.
Author
Owner

@llamafilm commented on GitHub (Dec 2, 2025):

I thought about this, and came up with a working demo, by adding an invert key to each permission JSON. To Jeremy's point in that old ticket, I don't think this would have any impact on cached permissions, since the top-level keys remain the same, we would just ignore that one.

There is a separate issue, that when a user has permission to edit some objects of a model but not all, the edit button leads to a 404. It would be nicer if the edit button did not appear at all. With this change, that issue remains the same.

But in the end, I decided not to pursue this, because it adds too much complexity and I figured out how to achieve our goals without it.

@llamafilm commented on GitHub (Dec 2, 2025): I thought about this, and came up with a working demo, by adding an `invert` key to each permission JSON. To Jeremy's point in that old ticket, I don't think this would have any impact on cached permissions, since the top-level keys remain the same, we would just ignore that one. There is a separate issue, that when a user has permission to edit _some_ objects of a model but not all, the edit button leads to a 404. It would be nicer if the edit button did not appear at all. With this change, that issue remains the same. But in the end, I decided not to pursue this, because it adds too much complexity and I figured out how to achieve our goals without it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#11848