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.3+ 1.2.3+
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.3.tar.gz (16.2 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.3-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: netbox_hidebox-1.2.3.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for netbox_hidebox-1.2.3.tar.gz
Algorithm Hash digest
SHA256 4f324001441ad5b3cb63138111b4d2220709e8c639e60623334e6911bb67ac6f
MD5 c3153ce029e849f8d92848ed3b3dca63
BLAKE2b-256 34ca5aa8787d0bee0012cf79acf438b58dc9d00184375a66600ec4f03c7d8bba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: netbox_hidebox-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for netbox_hidebox-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 07fea7f565b0b0c1e5183efee632e9c9b5a8641e420ca2b4e27c37aa605d4ced
MD5 9c94c26dda292cec1eef3d8b1995a2c7
BLAKE2b-256 ac1b539340712e2661d476bf7a6b7db91fb4a962c42e3647bc4bf2ef0c55e51f

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