Skip to main content

Hide Unwanted Fields Based On User-Groups

Project description

NetBox HideBox Plugin

NetBox HideBox is a plugin for NetBox that allows you to dynamically hide form fields based on the user’s group membership. This can be useful for restricting access to certain form fields depending on the user’s role or group in your organization.

Table of Contents

Features

  • Dynamically hide fields on NetBox forms based on user group membership.
  • Easy configuration.
  • Applies to any form related to a specific model in NetBox.
  • Granular control of field visibility for multiple user groups.

Requirements

  • netbox 4.0+
  • python 3.11+

Compatibility Matrix

NetBox Version Plugin Version
4.0+ 1.0+

Installation

To install the NetBox HideBox plugin, follow these steps:

  1. Clone the Repository or add the plugin to your project’s requirements:

    pip install netbox-hidebox
    
  2. Enable the Plugin in your NetBox configuration file (configuration.py):

    PLUGINS = [
       'netbox_hidebox',
    ]
    
  3. Configure Plugin Settings (see Configuration for details).

  4. Restart NetBox to apply changes:

    sudo systemctl restart netbox
    

Configuration

The core of the plugin is controlled by the HIDDEN_FIELDS setting in your settings.py or configuration.py file. This is where you define which fields to hide for which models and specify the user groups that are exempt from hiding.

Plugin Configuration Structure

In your NetBox configuration (configuration.py):

PLUGINS_CONFIG = {
    'netbox_hidebox': {
        'HIDDEN_FIELDS': {
            # Model identifier: {'field_name': ['excluded_group1', 'excluded_group2']}
            'app_label.model_name': {
                'field_name1': ['Group A', 'Group B'],  # Field hidden if user not in Group A or Group B
                'field_name2': ['Group C'],              # Field hidden if user not in Group C
            },
            'ipam.ipaddress': {
                'status': [],          # Leave Empty to hide for all Groups
            }
        }
    }
}

In your NetBox setting (settings.py):

MIDDLEWARE = [
    'netbox_hidebox.middleware.RequestMiddleware',  # Place it early in the list; recommended to place before the first netbox-middleware
    # Other middleware...
]

Explanation

  • app_label.model_name: The full identifier of the model (e.g., ipam.ipaddress).
  • field_name: The name of the field you want to hide (e.g., status).
  • excluded_groups: A list of user group names. If the user is not in any of these groups, the field will be hidden.

Usage

Once configured, the plugin will automatically hide fields on relevant forms based on the user’s group membership.

Example Scenario

Suppose you have the following configuration:

PLUGINS_CONFIG = {
    'netbox_hidebox': {
        'HIDDEN_FIELDS': {
            'ipam.ipaddress': {
                'description': ['Network Engineers', 'Admins'],
                'vrf': ['Admins'],
            }
        }
    }
}
  • description field in the IP Address form will be hidden for users who are not in the "Network Engineers" or "Admins" group.
  • vrf field will only be visible to users in the "Admins" group.

Adding/Removing Fields

To modify the configuration:

  • Edit the HIDDEN_FIELDS section in configuration.py.
  • Restart NetBox to apply the changes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netbox_hidebox-1.2.1.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netbox_hidebox-1.2.1-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file netbox_hidebox-1.2.1.tar.gz.

File metadata

  • Download URL: netbox_hidebox-1.2.1.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for netbox_hidebox-1.2.1.tar.gz
Algorithm Hash digest
SHA256 16be0837267adb2047305de964e49d6eafd7bc4b92d0968c15975f172fea2fbb
MD5 df6849f7dea557abd10b792f6273b3b1
BLAKE2b-256 57c651fc0eee8ab7817ff750e7d9424053dcc58fa54ff5241002b4f5d5619fda

See more details on using hashes here.

File details

Details for the file netbox_hidebox-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: netbox_hidebox-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for netbox_hidebox-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1cc8ce38c02bf41f44ea3ea6f6be6f1ce4b409b68a6c8f9f5258b63047ab2cee
MD5 e1daabe4ab1097cf725e297add4211cf
BLAKE2b-256 a5ea70cc819b4bc163309083fe387cc94e74a5e0cedfe5fff2d457a519bd078f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page