[PR #4705] [MERGED] #554: Implement object-based permissions #12903

Closed
opened 2025-12-29 22:24:17 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/4705
Author: @jeremystretch
Created: 6/1/2020
Status: Merged
Merged: 6/3/2020
Merged by: @jeremystretch

Base: develop-2.9Head: 554-object-permissions


📝 Commits (10+)

  • 6624fc6 Initial work on #554 (WIP)
  • 4b5d649 Introduced ObjectPermissionRequiredMixin
  • 06aca2e Merge branch 'develop-2.9' into 554-object-permissions
  • 63f842c Implement ObjectPermissionManager
  • daa2c6f Always pass obj=None to ModelBackend
  • c90f680 Cache object-level permissions on the User instance for evaluation
  • a275a30 Reimplement the ViewExemptModelBackend to explicitly cache all exempted view permissions on the User instance
  • 94d0ebb Fix ObjectPermission attribute consolidation
  • be5962f ObjectPermissionRequiredMixin should exempt superusers
  • f54fb67 Add object-level support to TokenPermissions

📊 Changes

76 files changed (+3402 additions, -1797 deletions)

View changed files

docs/administration/permissions.md (+43 -0)
📝 docs/configuration/optional-settings.md (+3 -3)
📝 docs/development/utility-views.md (+4 -0)
docs/models/users/objectpermission.md (+36 -0)
docs/release-notes/version-2.9.md (+18 -0)
📝 mkdocs.yml (+1 -0)
📝 netbox/circuits/models.py (+7 -1)
📝 netbox/circuits/querysets.py (+4 -2)
📝 netbox/circuits/urls.py (+5 -6)
📝 netbox/circuits/views.py (+77 -91)
📝 netbox/dcim/api/views.py (+1 -1)
📝 netbox/dcim/migrations/0041_napalm_integration.py (+1 -1)
📝 netbox/dcim/migrations/0089_deterministic_ordering.py (+1 -1)
📝 netbox/dcim/migrations/0095_primary_model_ordering.py (+1 -1)
📝 netbox/dcim/models/__init__.py (+32 -7)
📝 netbox/dcim/models/device_component_templates.py (+2 -0)
📝 netbox/dcim/models/device_components.py (+3 -0)
📝 netbox/dcim/tests/test_views.py (+35 -17)
📝 netbox/dcim/urls.py (+15 -15)
📝 netbox/dcim/views.py (+445 -661)

...and 56 more files

📄 Description

Closes #554: Implement object-based permissions

  • Introduce the new users.ObjectPermission model for tracking object-based permissions assignment (replaces the built-in Permission model)
  • Introduce RestrictedQuerySet to provide the restrict() method for filtering querysets based on assigned permissions
  • Rewrite a lot of the existing views and tests to accommodate the new permissions framework

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/4705 **Author:** [@jeremystretch](https://github.com/jeremystretch) **Created:** 6/1/2020 **Status:** ✅ Merged **Merged:** 6/3/2020 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `develop-2.9` ← **Head:** `554-object-permissions` --- ### 📝 Commits (10+) - [`6624fc6`](https://github.com/netbox-community/netbox/commit/6624fc607602502bd40f7124cc98bb050d96c01c) Initial work on #554 (WIP) - [`4b5d649`](https://github.com/netbox-community/netbox/commit/4b5d64939df2b187306e58dcf313915968dbb3b8) Introduced ObjectPermissionRequiredMixin - [`06aca2e`](https://github.com/netbox-community/netbox/commit/06aca2e1d52b5b557084e7e090a7a3cb78842c4c) Merge branch 'develop-2.9' into 554-object-permissions - [`63f842c`](https://github.com/netbox-community/netbox/commit/63f842c7db791e68221e888e0c16403a0281ff93) Implement ObjectPermissionManager - [`daa2c6f`](https://github.com/netbox-community/netbox/commit/daa2c6ff215cdef5f9f99b74cd12838a1a8a5a9b) Always pass obj=None to ModelBackend - [`c90f680`](https://github.com/netbox-community/netbox/commit/c90f680284838475b1ed8dec45d33a4c10f47c22) Cache object-level permissions on the User instance for evaluation - [`a275a30`](https://github.com/netbox-community/netbox/commit/a275a30dcae507d42a1da0c319c44d73691e1de3) Reimplement the ViewExemptModelBackend to explicitly cache all exempted view permissions on the User instance - [`94d0ebb`](https://github.com/netbox-community/netbox/commit/94d0ebbd7df8f45c7206edadeac02fa9fcfb9266) Fix ObjectPermission attribute consolidation - [`be5962f`](https://github.com/netbox-community/netbox/commit/be5962fb3a409b12fcc768fdff7c0aec17739e27) ObjectPermissionRequiredMixin should exempt superusers - [`f54fb67`](https://github.com/netbox-community/netbox/commit/f54fb67efc621a5f0198dc7ac525e44476a5381a) Add object-level support to TokenPermissions ### 📊 Changes **76 files changed** (+3402 additions, -1797 deletions) <details> <summary>View changed files</summary> ➕ `docs/administration/permissions.md` (+43 -0) 📝 `docs/configuration/optional-settings.md` (+3 -3) 📝 `docs/development/utility-views.md` (+4 -0) ➕ `docs/models/users/objectpermission.md` (+36 -0) ➕ `docs/release-notes/version-2.9.md` (+18 -0) 📝 `mkdocs.yml` (+1 -0) 📝 `netbox/circuits/models.py` (+7 -1) 📝 `netbox/circuits/querysets.py` (+4 -2) 📝 `netbox/circuits/urls.py` (+5 -6) 📝 `netbox/circuits/views.py` (+77 -91) 📝 `netbox/dcim/api/views.py` (+1 -1) 📝 `netbox/dcim/migrations/0041_napalm_integration.py` (+1 -1) 📝 `netbox/dcim/migrations/0089_deterministic_ordering.py` (+1 -1) 📝 `netbox/dcim/migrations/0095_primary_model_ordering.py` (+1 -1) 📝 `netbox/dcim/models/__init__.py` (+32 -7) 📝 `netbox/dcim/models/device_component_templates.py` (+2 -0) 📝 `netbox/dcim/models/device_components.py` (+3 -0) 📝 `netbox/dcim/tests/test_views.py` (+35 -17) 📝 `netbox/dcim/urls.py` (+15 -15) 📝 `netbox/dcim/views.py` (+445 -661) _...and 56 more files_ </details> ### 📄 Description ### Closes #554: Implement object-based permissions - Introduce the new users.ObjectPermission model for tracking object-based permissions assignment (replaces the built-in Permission model) - Introduce RestrictedQuerySet to provide the `restrict()` method for filtering querysets based on assigned permissions - Rewrite a lot of the existing views and tests to accommodate the new permissions framework --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 22:24:17 +01:00
adam closed this issue 2025-12-29 22:24:17 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#12903