Object based permissions for Interface by name #5405
-
I've been messing around with object based permissions. Basically I'm trying to restrict certain user/group to certain devices, most filtering is done by "if contains [word]" or "if starts with [word]" for this scenario. It's working well for device, ipam | VRF, virtualization | virtual machine, virtualization and some others. However, I can't seem to setup constraints for "dcim > interface" properly. At the moment, the user can see the devices I've filtered for in the permissions but not the interfaces under that device. I've tried selecting "dcim > interface" object type under permissions and then tested a bunch of queries under Constraints. I want the user to see the interfaces if it has access to that device. I've tried using
I can get it to filter by name but that ends up filtering for the interface name itself (ex. swp21, swp5 etc.) and not the device name. Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
You can reference the fields of related objects by joining them with a double underscore ("dunder"), similar to how you would you dots in Python. In this case, you want to reference the parent device's
This is analogous to referencing
|
Beta Was this translation helpful? Give feedback.
-
Nevermind, figured it out. Apparently |
Beta Was this translation helpful? Give feedback.
-
Nice! Hi, can you explain how that works? Interface isn't one of the IPAddress object methods as it was removed in v2.9+ as you have pointed out from the changelog |
Beta Was this translation helpful? Give feedback.
Nevermind, figured it out. Apparently
assigned_object
needs to be replaced withinterface
. So instead of the query being{"assigned_object__device__name__icontains": "-abc"}
, it becomes{"interface__device__name__icontains": "abc"}