Skip to main content

Opinionated RBAC for NetBox

Project description

Introduction

This package is an opinionated implementation of role based access control for NetBox.

It completely replaces the default authentication backend, using Active Directory for authentication and determining group membership. A user's roles are updated only on login, and are stored in the database.

Once installed, a user may view their roles.

Installation

$ pip3 install netbox-rbac

Configuration

Add the following to urls.py.

_patterns += [
	path('', include('netbox_rbac.urls') ),
]

Add the following to settings.py. Either the LDAP or MOCK driver can be used, but not both.

AUTHENTICATION_BACKENDS = [
    'netbox_rbac.backend.Backend',
]

INSTALLED_APPS += (
	'netbox_rbac',
)

MIDDLEWARE += (
	'netbox_rbac.middleware.Middleware',
)

REST_FRAMEWORK.update({
	'DEFAULT_PERMISSION_CLASSES': (
		'netbox_rbac.api.TokenPermissions',
		'netbox.api.TokenPermissions',
	)
})

LOGGING.update({
	'loggers': {
		'netbox_rbac': {
			'handlers': ['console'],
			'level':     'INFO',
		},
	},
})

LDAP

RBAC = {
	'AUTH': {
		'LDAP': {
			'domain': 'COMPANY.COM',
			'server': 'ldap://ldap.company.com:3268',
			'search': {
				'group': {
					'base':   'OU=Groups,DC=company,DC=com',
					'filter': '(&(sAMAccountName=%s)(objectClass=group))',
				},
				'member': {
					'base':   'OU=Accounts,DC=company,DC=com',
					'filter': '(&(sAMAccountName=%s)(memberOf:1.2.840.113556.1.4.1941:=%s))',
				},
				'user': {
					'base':   'OU=Accounts,DC=company,DC=com',
					'filter': '(&(sAMAccountName=%s)(objectClass=user))',
				},
			},
		},
	},
	'RULE': [
		'/opt/netbox-rules/rules.yaml',
		'https://rules.company.com/rules.yaml',
	],
}

Mock

RBAC = {
	'AUTH': {
		'MOCK': {
			'users': [{
				'username': 'ebusto',
				'password': 'pw12345',
				'email':    'ebusto@nvidia.com',
				'first_name': 'Eric',
				'last_name':  'Busto',
				'groups': ['Access-NetBox-Read', 'Access-NetBox-Admin-DCIM'],
			}],
		},
	},
	'RULE': [
		'/opt/netbox-rules/rules.yaml',
		'https://rules.company.com/rules.yaml',
	],
}

Database

Generate and apply RBAC model migrations.

$ ./manage.py makemigrations netbox_rbac
$ ./manage.py showmigrations
$ ./manage.py migrate

Rules

See the example rules, and documentation. The rule paths can be local files or URLs, and the backend will try each path in turn until it succeeds.

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-rbac-1.0.15.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

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

netbox_rbac-1.0.15-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file netbox-rbac-1.0.15.tar.gz.

File metadata

  • Download URL: netbox-rbac-1.0.15.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.6

File hashes

Hashes for netbox-rbac-1.0.15.tar.gz
Algorithm Hash digest
SHA256 6c167aad6bf0918f4fa762795362dc2804becfcea1bcbe4498c90274205de2db
MD5 f14192c8564cd8272a345a45f6294bbf
BLAKE2b-256 6259c3938e09c085453cada01b4cc5d73b3b3a355163b025889e640d081a2143

See more details on using hashes here.

File details

Details for the file netbox_rbac-1.0.15-py3-none-any.whl.

File metadata

  • Download URL: netbox_rbac-1.0.15-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/57.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.6

File hashes

Hashes for netbox_rbac-1.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 4f7603ca37d675e3f916cd67d2d55aae45a292c184568eb358216003c4fd84ce
MD5 1d832b67e53fd9c149dcb2f335fddded
BLAKE2b-256 473981fc4be31d5ff37968da585368140112ba3a35ac36c687cf04deab6f51d5

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