diff --git a/.github/ISSUE_TEMPLATE/02-bug_report.yaml b/.github/ISSUE_TEMPLATE/02-bug_report.yaml index f25b70b19..de92b3b8d 100644 --- a/.github/ISSUE_TEMPLATE/02-bug_report.yaml +++ b/.github/ISSUE_TEMPLATE/02-bug_report.yaml @@ -35,9 +35,9 @@ body: label: Python Version description: What version of Python are you currently running? options: - - "3.10" - - "3.11" - "3.12" + - "3.13" + - "3.14" validations: required: true - type: textarea diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85070d98e..1cd9b9463 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: NETBOX_CONFIGURATION: netbox.configuration_testing strategy: matrix: - python-version: ['3.10', '3.11', '3.12'] + python-version: ['3.12', '3.13'] node-version: ['20.x'] services: redis: diff --git a/docs/administration/authentication/overview.md b/docs/administration/authentication/overview.md index 19c86a4c0..6b805ee92 100644 --- a/docs/administration/authentication/overview.md +++ b/docs/administration/authentication/overview.md @@ -2,7 +2,7 @@ ## Local Authentication -Local user accounts and groups can be created in NetBox under the "Authentication" section in the "Admin" menu. This section is available only to users with the "staff" permission enabled. +Local user accounts and groups can be created in NetBox under the "Authentication" section in the "Admin" menu. At a minimum, each user account must have a username and password set. User accounts may also denote a first name, last name, and email address. [Permissions](../permissions.md) may also be assigned to individual users and/or groups as needed. diff --git a/docs/configuration/remote-authentication.md b/docs/configuration/remote-authentication.md index 5d5f1ee58..2dbb689c2 100644 --- a/docs/configuration/remote-authentication.md +++ b/docs/configuration/remote-authentication.md @@ -127,19 +127,3 @@ The list of groups that promote an remote User to Superuser on Login. If group i Default: `[]` (Empty list) The list of users that get promoted to Superuser on Login. If user isn't present in list on next Login, the Role gets revoked. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` ) - ---- - -## REMOTE_AUTH_STAFF_GROUPS - -Default: `[]` (Empty list) - -The list of groups that promote an remote User to Staff on Login. If group isn't present on next Login, the Role gets revoked. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` ) - ---- - -## REMOTE_AUTH_STAFF_USERS - -Default: `[]` (Empty list) - -The list of users that get promoted to Staff on Login. If user isn't present in list on next Login, the Role gets revoked. (Requires `REMOTE_AUTH_ENABLED` and `REMOTE_AUTH_GROUP_SYNC_ENABLED` ) diff --git a/docs/development/getting-started.md b/docs/development/getting-started.md index 8add82c90..956226760 100644 --- a/docs/development/getting-started.md +++ b/docs/development/getting-started.md @@ -7,7 +7,7 @@ Getting started with NetBox development is pretty straightforward, and should fe * A Linux system or compatible environment * A PostgreSQL server, which can be installed locally [per the documentation](../installation/1-postgresql.md) * A Redis server, which can also be [installed locally](../installation/2-redis.md) -* Python 3.10 or later +* Python 3.12 or later ### 1. Fork the Repo diff --git a/docs/installation/3-netbox.md b/docs/installation/3-netbox.md index acf04dc2a..c192a3094 100644 --- a/docs/installation/3-netbox.md +++ b/docs/installation/3-netbox.md @@ -6,8 +6,8 @@ This section of the documentation discusses installing and configuring the NetBo Begin by installing all system packages required by NetBox and its dependencies. -!!! warning "Python 3.10 or later required" - NetBox supports Python 3.10, 3.11, and 3.12. +!!! warning "Python 3.12 or later required" + NetBox supports only Python 3.12 or later. ```no-highlight sudo apt install -y python3 python3-pip python3-venv python3-dev \ @@ -15,7 +15,7 @@ build-essential libxml2-dev libxslt1-dev libffi-dev libpq-dev \ libssl-dev zlib1g-dev ``` -Before continuing, check that your installed Python version is at least 3.10: +Before continuing, check that your installed Python version is at least 3.12: ```no-highlight python3 -V @@ -235,10 +235,10 @@ Once NetBox has been configured, we're ready to proceed with the actual installa sudo /opt/netbox/upgrade.sh ``` -Note that **Python 3.10 or later is required** for NetBox v4.0 and later releases. If the default Python installation on your server is set to a lesser version, pass the path to the supported installation as an environment variable named `PYTHON`. (Note that the environment variable must be passed _after_ the `sudo` command.) +Note that **Python 3.12 or later is required** for NetBox v4.5 and later releases. If the default Python installation on your server is set to a lesser version, pass the path to the supported installation as an environment variable named `PYTHON`. (Note that the environment variable must be passed _after_ the `sudo` command.) ```no-highlight -sudo PYTHON=/usr/bin/python3.10 /opt/netbox/upgrade.sh +sudo PYTHON=/usr/bin/python3.12 /opt/netbox/upgrade.sh ``` !!! note diff --git a/docs/installation/4a-gunicorn.md b/docs/installation/4a-gunicorn.md index 3aca4ef0e..91bbcd0e5 100644 --- a/docs/installation/4a-gunicorn.md +++ b/docs/installation/4a-gunicorn.md @@ -60,6 +60,3 @@ You should see output similar to the following: If the NetBox service fails to start, issue the command `journalctl -eu netbox` to check for log messages that may indicate the problem. Once you've verified that the WSGI workers are up and running, move on to HTTP server setup. - -!!! note - There is a bug in the current stable release of gunicorn (v21.2.0) where automatic restarts of the worker processes can result in 502 errors under heavy load. (See [gunicorn bug #3038](https://github.com/benoitc/gunicorn/issues/3038) for more detail.) Users who encounter this issue may opt to downgrade to an earlier, unaffected release of gunicorn (`pip install gunicorn==20.1.0`). Note, however, that this earlier release does not officially support Python 3.11. diff --git a/docs/installation/6-ldap.md b/docs/installation/6-ldap.md index 7de9f116d..4d27f2f01 100644 --- a/docs/installation/6-ldap.md +++ b/docs/installation/6-ldap.md @@ -121,7 +121,6 @@ AUTH_LDAP_MIRROR_GROUPS = True # Define special user types using groups. Exercise great caution when assigning superuser status. AUTH_LDAP_USER_FLAGS_BY_GROUP = { "is_active": "cn=active,ou=groups,dc=example,dc=com", - "is_staff": "cn=staff,ou=groups,dc=example,dc=com", "is_superuser": "cn=superuser,ou=groups,dc=example,dc=com" } @@ -134,7 +133,6 @@ AUTH_LDAP_CACHE_TIMEOUT = 3600 ``` * `is_active` - All users must be mapped to at least this group to enable authentication. Without this, users cannot log in. -* `is_staff` - Users mapped to this group are enabled for access to the administration tools; this is the equivalent of checking the "staff status" box on a manually created user. This doesn't grant any specific permissions. * `is_superuser` - Users mapped to this group will be granted superuser status. Superusers are implicitly granted all permissions. !!! warning @@ -248,7 +246,6 @@ AUTH_LDAP_MIRROR_GROUPS = True # Define special user types using groups. Exercise great caution when assigning superuser status. AUTH_LDAP_USER_FLAGS_BY_GROUP = { "is_active": "cn=active,ou=groups,dc=example,dc=com", - "is_staff": "cn=staff,ou=groups,dc=example,dc=com", "is_superuser": "cn=superuser,ou=groups,dc=example,dc=com" } diff --git a/docs/installation/index.md b/docs/installation/index.md index aefa39d17..73bf1220c 100644 --- a/docs/installation/index.md +++ b/docs/installation/index.md @@ -27,7 +27,7 @@ The following sections detail how to set up a new instance of NetBox: | Dependency | Supported Versions | |------------|--------------------| -| Python | 3.10, 3.11, 3.12 | +| Python | 3.12, 3.13, 3.14 | | PostgreSQL | 14+ | | Redis | 4.0+ | diff --git a/docs/installation/upgrading.md b/docs/installation/upgrading.md index cf0a16754..ce5282b04 100644 --- a/docs/installation/upgrading.md +++ b/docs/installation/upgrading.md @@ -19,7 +19,7 @@ NetBox requires the following dependencies: | Dependency | Supported Versions | |------------|--------------------| -| Python | 3.10, 3.11, 3.12 | +| Python | 3.12, 3.13, 3.14 | | PostgreSQL | 14+ | | Redis | 4.0+ | @@ -27,6 +27,7 @@ NetBox requires the following dependencies: | NetBox Version | Python min | Python max | PostgreSQL min | Redis min | Documentation | |:--------------:|:----------:|:----------:|:--------------:|:---------:|:-----------------------------------------------------------------------------------------:| +| 4.5 | 3.12 | 3.14 | 14 | 4.0 | [Link](https://github.com/netbox-community/netbox/blob/v4.5.0/docs/installation/index.md) | | 4.4 | 3.10 | 3.12 | 14 | 4.0 | [Link](https://github.com/netbox-community/netbox/blob/v4.4.0/docs/installation/index.md) | | 4.3 | 3.10 | 3.12 | 14 | 4.0 | [Link](https://github.com/netbox-community/netbox/blob/v4.3.0/docs/installation/index.md) | | 4.2 | 3.10 | 3.12 | 13 | 4.0 | [Link](https://github.com/netbox-community/netbox/blob/v4.2.0/docs/installation/index.md) | @@ -130,7 +131,7 @@ sudo ./upgrade.sh If the default version of Python is not at least 3.10, you'll need to pass the path to a supported Python version as an environment variable when calling the upgrade script. For example: ```no-highlight - sudo PYTHON=/usr/bin/python3.10 ./upgrade.sh + sudo PYTHON=/usr/bin/python3.12 ./upgrade.sh ``` !!! note diff --git a/docs/plugins/development/index.md b/docs/plugins/development/index.md index 56bde5e41..df8876391 100644 --- a/docs/plugins/development/index.md +++ b/docs/plugins/development/index.md @@ -173,12 +173,12 @@ classifiers=[ 'Intended Audience :: Developers', 'Natural Language :: English', "Programming Language :: Python :: 3 :: Only", - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', + 'Programming Language :: Python :: 3.14', ] -requires-python = ">=3.10.0" +requires-python = ">=3.12.0" ``` @@ -195,7 +195,7 @@ python3 -m venv ~/.virtualenvs/my_plugin You can make NetBox available within this environment by creating a path file pointing to its location. This will add NetBox to the Python path upon activation. (Be sure to adjust the command below to specify your actual virtual environment path, Python version, and NetBox installation.) ```shell -echo /opt/netbox/netbox > $VENV/lib/python3.10/site-packages/netbox.pth +echo /opt/netbox/netbox > $VENV/lib/python3.12/site-packages/netbox.pth ``` ## Development Installation diff --git a/docs/plugins/development/navigation.md b/docs/plugins/development/navigation.md index b5e2694b4..bb855bcea 100644 --- a/docs/plugins/development/navigation.md +++ b/docs/plugins/development/navigation.md @@ -64,14 +64,17 @@ item1 = PluginMenuItem( A `PluginMenuItem` has the following attributes: -| Attribute | Required | Description | -|-----------------|----------|----------------------------------------------------------------------------------------------------------| -| `link` | Yes | Name of the URL path to which this menu item links | -| `link_text` | Yes | The text presented to the user | -| `permissions` | - | A list of permissions required to display this link | -| `auth_required` | - | Display only for authenticated users | -| `staff_only` | - | Display only for users who have `is_staff` set to true (any specified permissions will also be required) | -| `buttons` | - | An iterable of PluginMenuButton instances to include | +| Attribute | Required | Description | +|-----------------|----------|------------------------------------------------------| +| `link` | Yes | Name of the URL path to which this menu item links | +| `link_text` | Yes | The text presented to the user | +| `permissions` | - | A list of permissions required to display this link | +| `auth_required` | - | Display only for authenticated users | +| `staff_only` | - | Display only for superusers | +| `buttons` | - | An iterable of PluginMenuButton instances to include | + +!!! note "Changed in NetBox v4.5" + In releases prior to NetBox v4.5, `staff_only` restricted display of a menu item to only users with `is_staff` set to True. In NetBox v4.5, the `is_staff` flag was removed from the user model. Menu items with `staff_only` set to True are now displayed only for superusers. ## Menu Buttons diff --git a/netbox/core/api/views.py b/netbox/core/api/views.py index e9569a717..afa30ce56 100644 --- a/netbox/core/api/views.py +++ b/netbox/core/api/views.py @@ -9,7 +9,6 @@ from drf_spectacular.utils import extend_schema from rest_framework import viewsets from rest_framework.decorators import action from rest_framework.exceptions import PermissionDenied -from rest_framework.permissions import IsAdminUser from rest_framework.response import Response from rest_framework.routers import APIRootView from rest_framework.viewsets import ReadOnlyModelViewSet @@ -24,6 +23,7 @@ from netbox.api.authentication import IsAuthenticatedOrLoginNotRequired from netbox.api.metadata import ContentTypeMetadata from netbox.api.pagination import LimitOffsetListPagination from netbox.api.viewsets import NetBoxModelViewSet, NetBoxReadOnlyModelViewSet +from utilities.api import IsSuperuser from . import serializers @@ -99,7 +99,7 @@ class BaseRQViewSet(viewsets.ViewSet): """ Base class for RQ view sets. Provides a list() method. Subclasses must implement get_data(). """ - permission_classes = [IsAdminUser] + permission_classes = [IsSuperuser] serializer_class = None def get_data(self): diff --git a/netbox/core/models/contenttypes.py b/netbox/core/models/contenttypes.py deleted file mode 100644 index 3d5c5e8b2..000000000 --- a/netbox/core/models/contenttypes.py +++ /dev/null @@ -1,3 +0,0 @@ -# TODO: Remove this module in NetBox v4.5 -# Provided for backward compatibility -from .object_types import * diff --git a/netbox/core/tests/test_api.py b/netbox/core/tests/test_api.py index 4a285bdb4..4d612e157 100644 --- a/netbox/core/tests/test_api.py +++ b/netbox/core/tests/test_api.py @@ -107,14 +107,14 @@ class ObjectTypeTest(APITestCase): def test_list_objects(self): object_type_count = ObjectType.objects.count() - response = self.client.get(reverse('extras-api:objecttype-list'), **self.header) + response = self.client.get(reverse('core-api:objecttype-list'), **self.header) self.assertHttpStatus(response, status.HTTP_200_OK) self.assertEqual(response.data['count'], object_type_count) def test_get_object(self): object_type = ObjectType.objects.first() - url = reverse('extras-api:objecttype-detail', kwargs={'pk': object_type.pk}) + url = reverse('core-api:objecttype-detail', kwargs={'pk': object_type.pk}) self.assertHttpStatus(self.client.get(url, **self.header), status.HTTP_200_OK) @@ -134,10 +134,7 @@ class BackgroundTaskTestCase(TestCase): Create a user and token for API calls. """ # Create the test user and assign permissions - self.user = User.objects.create_user(username='testuser') - self.user.is_staff = True - self.user.is_active = True - self.user.save() + self.user = User.objects.create_user(username='testuser', is_active=True) self.token = Token.objects.create(user=self.user) self.header = {'HTTP_AUTHORIZATION': f'Token {self.token.key}'} @@ -150,13 +147,11 @@ class BackgroundTaskTestCase(TestCase): url = reverse('core-api:rqqueue-list') # Attempt to load view without permission - self.user.is_staff = False - self.user.save() response = self.client.get(url, **self.header) self.assertEqual(response.status_code, 403) # Load view with permission - self.user.is_staff = True + self.user.is_superuser = True self.user.save() response = self.client.get(url, **self.header) self.assertEqual(response.status_code, 200) @@ -165,7 +160,16 @@ class BackgroundTaskTestCase(TestCase): self.assertIn('low', str(response.content)) def test_background_queue(self): - response = self.client.get(reverse('core-api:rqqueue-detail', args=['default']), **self.header) + url = reverse('core-api:rqqueue-detail', args=['default']) + + # Attempt to load view without permission + response = self.client.get(url, **self.header) + self.assertEqual(response.status_code, 403) + + # Load view with permission + self.user.is_superuser = True + self.user.save() + response = self.client.get(url, **self.header) self.assertEqual(response.status_code, 200) self.assertIn('default', str(response.content)) self.assertIn('oldest_job_timestamp', str(response.content)) @@ -174,8 +178,16 @@ class BackgroundTaskTestCase(TestCase): def test_background_task_list(self): queue = get_queue('default') queue.enqueue(self.dummy_job_default) + url = reverse('core-api:rqtask-list') - response = self.client.get(reverse('core-api:rqtask-list'), **self.header) + # Attempt to load view without permission + response = self.client.get(url, **self.header) + self.assertEqual(response.status_code, 403) + + # Load view with permission + self.user.is_superuser = True + self.user.save() + response = self.client.get(url, **self.header) self.assertEqual(response.status_code, 200) self.assertIn('origin', str(response.content)) self.assertIn('core.tests.test_api.BackgroundTaskTestCase.dummy_job_default()', str(response.content)) @@ -183,8 +195,16 @@ class BackgroundTaskTestCase(TestCase): def test_background_task(self): queue = get_queue('default') job = queue.enqueue(self.dummy_job_default) + url = reverse('core-api:rqtask-detail', args=[job.id]) - response = self.client.get(reverse('core-api:rqtask-detail', args=[job.id]), **self.header) + # Attempt to load view without permission + response = self.client.get(url, **self.header) + self.assertEqual(response.status_code, 403) + + # Load view with permission + self.user.is_superuser = True + self.user.save() + response = self.client.get(url, **self.header) self.assertEqual(response.status_code, 200) self.assertIn(str(job.id), str(response.content)) self.assertIn('origin', str(response.content)) @@ -194,45 +214,65 @@ class BackgroundTaskTestCase(TestCase): def test_background_task_delete(self): queue = get_queue('default') job = queue.enqueue(self.dummy_job_default) + url = reverse('core-api:rqtask-delete', args=[job.id]) - response = self.client.post(reverse('core-api:rqtask-delete', args=[job.id]), **self.header) + # Attempt to load view without permission + response = self.client.get(url, **self.header) + self.assertEqual(response.status_code, 403) + + # Load view with permission + self.user.is_superuser = True + self.user.save() + response = self.client.post(url, **self.header) self.assertEqual(response.status_code, 200) self.assertFalse(RQ_Job.exists(job.id, connection=queue.connection)) queue = get_queue('default') self.assertNotIn(job.id, queue.job_ids) def test_background_task_requeue(self): - queue = get_queue('default') - # Enqueue & run a job that will fail + queue = get_queue('default') job = queue.enqueue(self.dummy_job_failing) worker = get_worker('default') with disable_logging(): worker.work(burst=True) self.assertTrue(job.is_failed) + url = reverse('core-api:rqtask-requeue', args=[job.id]) + + # Attempt to requeue the job without permission + response = self.client.post(url, **self.header) + self.assertEqual(response.status_code, 403) # Re-enqueue the failed job and check that its status has been reset - response = self.client.post(reverse('core-api:rqtask-requeue', args=[job.id]), **self.header) + self.user.is_superuser = True + self.user.save() + response = self.client.post(url, **self.header) self.assertEqual(response.status_code, 200) job = RQ_Job.fetch(job.id, queue.connection) self.assertFalse(job.is_failed) def test_background_task_enqueue(self): - queue = get_queue('default') - # Enqueue some jobs that each depends on its predecessor + queue = get_queue('default') job = previous_job = None for _ in range(0, 3): job = queue.enqueue(self.dummy_job_default, depends_on=previous_job) previous_job = job + url = reverse('core-api:rqtask-enqueue', args=[job.id]) # Check that the last job to be enqueued has a status of deferred self.assertIsNotNone(job) self.assertEqual(job.get_status(), JobStatus.DEFERRED) self.assertIsNone(job.enqueued_at) + # Attempt to force-enqueue the job without permission + response = self.client.post(url, **self.header) + self.assertEqual(response.status_code, 403) + # Force-enqueue the deferred job - response = self.client.post(reverse('core-api:rqtask-enqueue', args=[job.id]), **self.header) + self.user.is_superuser = True + self.user.save() + response = self.client.post(url, **self.header) self.assertEqual(response.status_code, 200) # Check that job's status is updated correctly @@ -242,19 +282,27 @@ class BackgroundTaskTestCase(TestCase): def test_background_task_stop(self): queue = get_queue('default') - worker = get_worker('default') job = queue.enqueue(self.dummy_job_default) worker.prepare_job_execution(job) - + url = reverse('core-api:rqtask-stop', args=[job.id]) self.assertEqual(job.get_status(), JobStatus.STARTED) - response = self.client.post(reverse('core-api:rqtask-stop', args=[job.id]), **self.header) + + # Attempt to stop the task without permission + response = self.client.post(url, **self.header) + self.assertEqual(response.status_code, 403) + + # Stop the task + self.user.is_superuser = True + self.user.save() + response = self.client.post(url, **self.header) self.assertEqual(response.status_code, 200) with disable_logging(): worker.monitor_work_horse(job, queue) # Sets the job as Failed and removes from Started started_job_registry = StartedJobRegistry(queue.name, connection=queue.connection) self.assertEqual(len(started_job_registry), 0) + # Verify that the task was cancelled canceled_job_registry = FailedJobRegistry(queue.name, connection=queue.connection) self.assertEqual(len(canceled_job_registry), 1) self.assertIn(job.id, canceled_job_registry) @@ -262,19 +310,34 @@ class BackgroundTaskTestCase(TestCase): def test_worker_list(self): worker1 = get_worker('default', name=uuid.uuid4().hex) worker1.register_birth() - worker2 = get_worker('high') worker2.register_birth() + url = reverse('core-api:rqworker-list') - response = self.client.get(reverse('core-api:rqworker-list'), **self.header) + # Attempt to fetch the worker list without permission + response = self.client.get(url, **self.header) + self.assertEqual(response.status_code, 403) + + # Fetch the worker list + self.user.is_superuser = True + self.user.save() + response = self.client.get(url, **self.header) self.assertEqual(response.status_code, 200) self.assertIn(str(worker1.name), str(response.content)) def test_worker(self): worker1 = get_worker('default', name=uuid.uuid4().hex) worker1.register_birth() + url = reverse('core-api:rqworker-detail', args=[worker1.name]) - response = self.client.get(reverse('core-api:rqworker-detail', args=[worker1.name]), **self.header) + # Attempt to fetch a worker without permission + response = self.client.get(url, **self.header) + self.assertEqual(response.status_code, 403) + + # Fetch the worker + self.user.is_superuser = True + self.user.save() + response = self.client.get(url, **self.header) self.assertEqual(response.status_code, 200) self.assertIn(str(worker1.name), str(response.content)) self.assertIn('birth_date', str(response.content)) diff --git a/netbox/core/tests/test_views.py b/netbox/core/tests/test_views.py index 1001243eb..2f0ef59e6 100644 --- a/netbox/core/tests/test_views.py +++ b/netbox/core/tests/test_views.py @@ -158,7 +158,7 @@ class BackgroundTaskTestCase(TestCase): def setUp(self): super().setUp() - self.user.is_staff = True + self.user.is_superuser = True self.user.is_active = True self.user.save() @@ -171,13 +171,13 @@ class BackgroundTaskTestCase(TestCase): url = reverse('core:background_queue_list') # Attempt to load view without permission - self.user.is_staff = False + self.user.is_superuser = False self.user.save() response = self.client.get(url) self.assertEqual(response.status_code, 403) # Load view with permission - self.user.is_staff = True + self.user.is_superuser = True self.user.save() response = self.client.get(url) self.assertEqual(response.status_code, 200) @@ -356,7 +356,7 @@ class SystemTestCase(TestCase): def setUp(self): super().setUp() - self.user.is_staff = True + self.user.is_superuser = True self.user.save() def test_system_view_default(self): diff --git a/netbox/core/views.py b/netbox/core/views.py index b18937308..aa3be7303 100644 --- a/netbox/core/views.py +++ b/netbox/core/views.py @@ -366,7 +366,7 @@ class ConfigRevisionRestoreView(ContentTypePermissionRequiredMixin, View): class BaseRQView(UserPassesTestMixin, View): def test_func(self): - return self.request.user.is_staff + return self.request.user.is_superuser class BackgroundQueueListView(TableMixin, BaseRQView): @@ -549,7 +549,7 @@ class WorkerView(BaseRQView): class SystemView(UserPassesTestMixin, View): def test_func(self): - return self.request.user.is_staff + return self.request.user.is_superuser def get(self, request): @@ -632,7 +632,7 @@ class BasePluginView(UserPassesTestMixin, View): CACHE_KEY_CATALOG_ERROR = 'plugins-catalog-error' def test_func(self): - return self.request.user.is_staff + return self.request.user.is_superuser def get_cached_plugins(self, request): catalog_plugins = {} diff --git a/netbox/extras/api/urls.py b/netbox/extras/api/urls.py index 3757157b4..52cf28b16 100644 --- a/netbox/extras/api/urls.py +++ b/netbox/extras/api/urls.py @@ -1,10 +1,8 @@ from django.urls import include, path -from core.api.views import ObjectTypeViewSet from netbox.api.routers import NetBoxRouter from . import views - router = NetBoxRouter() router.APIRootView = views.ExtrasRootView @@ -29,9 +27,6 @@ router.register('config-context-profiles', views.ConfigContextProfileViewSet) router.register('config-templates', views.ConfigTemplateViewSet) router.register('scripts', views.ScriptViewSet, basename='script') -# TODO: Remove in NetBox v4.5 -router.register('object-types', ObjectTypeViewSet) - app_name = 'extras-api' urlpatterns = [ path('dashboard/', views.DashboardView.as_view(), name='dashboard'), diff --git a/netbox/netbox/authentication/__init__.py b/netbox/netbox/authentication/__init__.py index 25f9b902c..8596c59ab 100644 --- a/netbox/netbox/authentication/__init__.py +++ b/netbox/netbox/authentication/__init__.py @@ -184,14 +184,13 @@ class RemoteUserBackend(_RemoteUserBackend): else: user.groups.clear() logger.debug(f"Stripping user {user} from Groups") + + # Evaluate superuser status user.is_superuser = self._is_superuser(user) logger.debug(f"User {user} is Superuser: {user.is_superuser}") logger.debug( f"User {user} should be Superuser: {self._is_superuser(user)}") - user.is_staff = self._is_staff(user) - logger.debug(f"User {user} is Staff: {user.is_staff}") - logger.debug(f"User {user} should be Staff: {self._is_staff(user)}") user.save() return user @@ -251,19 +250,8 @@ class RemoteUserBackend(_RemoteUserBackend): return bool(result) def _is_staff(self, user): - logger = logging.getLogger('netbox.auth.RemoteUserBackend') - staff_groups = settings.REMOTE_AUTH_STAFF_GROUPS - logger.debug(f"Superuser Groups: {staff_groups}") - staff_users = settings.REMOTE_AUTH_STAFF_USERS - logger.debug(f"Staff Users :{staff_users}") - user_groups = set() - for g in user.groups.all(): - user_groups.add(g.name) - logger.debug(f"User {user.username} is in Groups:{user_groups}") - result = user.username in staff_users or ( - set(user_groups) & set(staff_groups)) - logger.debug(f"User {user.username} in Staff Users :{result}") - return bool(result) + # Retain for pre-v4.5 compatibility + return user.is_superuser def configure_user(self, request, user): logger = logging.getLogger('netbox.auth.RemoteUserBackend') diff --git a/netbox/netbox/plugins/views.py b/netbox/netbox/plugins/views.py index feee78e82..f413b8032 100644 --- a/netbox/netbox/plugins/views.py +++ b/netbox/netbox/plugins/views.py @@ -3,12 +3,12 @@ from collections import OrderedDict from django.apps import apps from django.urls.exceptions import NoReverseMatch from drf_spectacular.utils import extend_schema -from rest_framework import permissions from rest_framework.response import Response from rest_framework.reverse import reverse from rest_framework.views import APIView from netbox.registry import registry +from utilities.api import IsSuperuser @extend_schema(exclude=True) @@ -16,7 +16,7 @@ class InstalledPluginsAPIView(APIView): """ API view for listing all installed plugins """ - permission_classes = [permissions.IsAdminUser] + permission_classes = [IsSuperuser] _ignore_model_permissions = True schema = None diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index c9eed75e1..a0a6225c3 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -31,9 +31,9 @@ VERSION = RELEASE.full_version # Retained for backward compatibility BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Validate Python version -if sys.version_info < (3, 10): +if sys.version_info < (3, 12): raise RuntimeError( - f"NetBox requires Python 3.10 or later. (Currently installed: Python {platform.python_version()})" + f"NetBox requires Python 3.12 or later. (Currently installed: Python {platform.python_version()})" ) # @@ -161,8 +161,6 @@ REMOTE_AUTH_SUPERUSERS = getattr(configuration, 'REMOTE_AUTH_SUPERUSERS', []) REMOTE_AUTH_USER_EMAIL = getattr(configuration, 'REMOTE_AUTH_USER_EMAIL', 'HTTP_REMOTE_USER_EMAIL') REMOTE_AUTH_USER_FIRST_NAME = getattr(configuration, 'REMOTE_AUTH_USER_FIRST_NAME', 'HTTP_REMOTE_USER_FIRST_NAME') REMOTE_AUTH_USER_LAST_NAME = getattr(configuration, 'REMOTE_AUTH_USER_LAST_NAME', 'HTTP_REMOTE_USER_LAST_NAME') -REMOTE_AUTH_STAFF_GROUPS = getattr(configuration, 'REMOTE_AUTH_STAFF_GROUPS', []) -REMOTE_AUTH_STAFF_USERS = getattr(configuration, 'REMOTE_AUTH_STAFF_USERS', []) # Required by extras/migrations/0109_script_models.py REPORTS_ROOT = getattr(configuration, 'REPORTS_ROOT', os.path.join(BASE_DIR, 'reports')).rstrip('/') RQ_DEFAULT_TIMEOUT = getattr(configuration, 'RQ_DEFAULT_TIMEOUT', 300) diff --git a/netbox/netbox/views/misc.py b/netbox/netbox/views/misc.py index ab995db66..4537f14c9 100644 --- a/netbox/netbox/views/misc.py +++ b/netbox/netbox/views/misc.py @@ -47,9 +47,9 @@ class HomeView(ConditionalLoginRequiredMixin, View): )) dashboard = get_default_dashboard(config=DEFAULT_DASHBOARD).get_layout() - # Check whether a new release is available. (Only for staff/superusers.) + # Check whether a new release is available. (Only for superusers.) new_release = None - if request.user.is_staff or request.user.is_superuser: + if request.user.is_superuser: latest_release = cache.get('latest_release') if latest_release: release_version, release_url = latest_release diff --git a/netbox/templates/account/profile.html b/netbox/templates/account/profile.html index 442cce9ba..8ef0db6e8 100644 --- a/netbox/templates/account/profile.html +++ b/netbox/templates/account/profile.html @@ -39,10 +39,6 @@
STATIC_ROOT: {{ settings.STATIC_ROOT }}STATIC_URL: {{ settings.STATIC_URL }}