RestrictedQuerySet uses user _object_perm_cache directly which is only set by ObjectPermissionBackend #4145

Closed
opened 2025-12-29 18:33:26 +01:00 by adam · 2 comments
Owner

Originally created by @Urth on GitHub (Sep 28, 2020).

Environment

  • Python version: 3.7.9
  • NetBox version: 2.9.4

Steps to Reproduce

  1. Authenticate non-superuser user with RemoteUserBackend or a custom backend that does not inherit from netbox' ObjectPermissionBackend.
  2. User will not be able to visit pages that use RestrictedQuerySet

Expected Behavior

Page to load as usual and skip object permissions if the configured authentication backend does not support it.

Observed Behavior

AttrributeError("'User' object has no attribute '_object_perm_cache'")

Originally created by @Urth on GitHub (Sep 28, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report, and that any plugins have been disabled. --> ### Environment * Python version: 3.7.9 * NetBox version: 2.9.4 <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox. Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a client library such as pynetbox. --> ### Steps to Reproduce 1. Authenticate non-superuser user with `RemoteUserBackend` or a custom backend that does not inherit from netbox' `ObjectPermissionBackend`. 2. User will not be able to visit pages that use `RestrictedQuerySet` <!-- What did you expect to happen? --> ### Expected Behavior Page to load as usual and skip object permissions if the configured authentication backend does not support it. <!-- What happened instead? --> ### Observed Behavior `AttrributeError("'User' object has no attribute '_object_perm_cache'")`
adam added the status: revisions needed label 2025-12-29 18:33:26 +01:00
adam closed this issue 2025-12-29 18:33:26 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 29, 2020):

Please share your relevant configuration and the complete stack trace.

@jeremystretch commented on GitHub (Sep 29, 2020): Please share your relevant configuration and the complete stack trace.
Author
Owner

@Urth commented on GitHub (Oct 1, 2020):

I thought authentication backends could be omitted if not used but this is not true for permissions which will be loaded from all available backends. So netbox.authentication.ObjectPermissionBackend must always be included even when not used to authenticate.

@Urth commented on GitHub (Oct 1, 2020): I thought authentication backends could be omitted if not used but this is not true for permissions which will be loaded from all available backends. So `netbox.authentication.ObjectPermissionBackend` must always be included even when not used to authenticate.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4145