Skip to content

Commit

Permalink
Merge pull request #4 from TheDJVG/daan/manual-installation-steps
Browse files Browse the repository at this point in the history
Manual installation steps
  • Loading branch information
TheDJVG authored Oct 10, 2024
2 parents b2f4050 + 8444f20 commit 95c026c
Show file tree
Hide file tree
Showing 7 changed files with 456 additions and 10 deletions.
347 changes: 347 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,353 @@ PLUGINS = [
]
```

### Validator installation
By default, the migration will install the validator for all models. If you're using a statically configured NetBox
instance you can use this `CUSTOM_VALIDATORS` block to install it for all models:
<details>
<summary>Show configuration snippet</summary>

```python
CUSTOM_VALIDATORS = {
"circuits.circuit": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"circuits.circuittermination": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"circuits.circuittype": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"circuits.provider": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"circuits.provideraccount": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"circuits.providernetwork": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.cable": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.cablepath": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.cabletermination": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.consoleport": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.consoleporttemplate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.consoleserverport": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.consoleserverporttemplate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.device": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.devicebay": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.devicebaytemplate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.devicerole": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.devicetype": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.frontport": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.frontporttemplate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.interface": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.interfacetemplate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.inventoryitem": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.inventoryitemrole": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.inventoryitemtemplate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.location": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.manufacturer": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.module": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.modulebay": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.modulebaytemplate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.moduletype": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.platform": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.powerfeed": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.poweroutlet": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.poweroutlettemplate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.powerpanel": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.powerport": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.powerporttemplate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.rack": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.rackreservation": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.rackrole": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.rearport": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.rearporttemplate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.region": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.site": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.sitegroup": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.virtualchassis": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"dcim.virtualdevicecontext": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.bookmark": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.branch": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.cachedvalue": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.configcontext": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.configtemplate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.customfield": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.customfieldchoiceset": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.customlink": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.dashboard": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.eventrule": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.exporttemplate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.imageattachment": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.journalentry": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.objectchange": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.reportmodule": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.savedfilter": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.script": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.scriptmodule": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.stagedchange": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.tag": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.taggeditem": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"extras.webhook": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.aggregate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.asn": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.asnrange": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.fhrpgroup": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.fhrpgroupassignment": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.ipaddress": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.iprange": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.prefix": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.rir": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.role": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.routetarget": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.service": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.servicetemplate": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.vlan": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.vlangroup": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"ipam.vrf": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"tenancy.contact": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"tenancy.contactassignment": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"tenancy.contactgroup": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"tenancy.contactrole": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"tenancy.tenant": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"tenancy.tenantgroup": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"virtualization.cluster": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"virtualization.clustergroup": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"virtualization.clustertype": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"virtualization.virtualdisk": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"virtualization.virtualmachine": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"virtualization.vminterface": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"vpn.ikepolicy": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"vpn.ikeproposal": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"vpn.ipsecpolicy": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"vpn.ipsecprofile": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"vpn.ipsecproposal": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"vpn.l2vpn": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"vpn.l2vpntermination": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"vpn.tunnel": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"vpn.tunnelgroup": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"vpn.tunneltermination": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"wireless.wirelesslan": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"wireless.wirelesslangroup": [
"netbox_field_permissions.validators.FieldPermissionValidator"
],
"wireless.wirelesslink": [
"netbox_field_permissions.validators.FieldPermissionValidator"
]
}
```
</details>

You can also view updated configuration on the `Plugins -> Field Permissions -> Manage Validator` page.

## Features

### Disallow changes to any user accessible field
Expand Down
3 changes: 2 additions & 1 deletion netbox_field_permissions/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def get_current_config(apps):
def write_static_configuration_messsage():
sys.stdout.write(
colorize(
"\n Static NetBox configuration detected. Please install customer validator manually!!",
"\n Static NetBox configuration detected. Please install plugin validator manually by "
"adding 'netbox_field_permissions.validators.FieldPermissionValidator' for each model.",
fg="yellow",
opts=("bold",),
)
Expand Down
2 changes: 1 addition & 1 deletion netbox_field_permissions/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
title="Add",
icon_class="mdi mdi-plus-thick",
permissions=("netbox_field_permissions.add_fieldpermission",),
)
),
],
),
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "generic/object_list.html" %}

{% block extra_controls %}
{% if user.is_superuser %}
{% if user.is_staff %}
<a href="{% url 'plugins:netbox_field_permissions:fieldpermission_manage' %}" class="btn btn-secondary" type="button">
<i class="mdi mdi-cog" aria-hidden="true"></i> Manage Validators</a>
{% endif %}
Expand Down
Loading

0 comments on commit 95c026c

Please sign in to comment.