Repository: netbox-community/netbox

Issue:
Removal of `staff_only=True` from Admin menu items
### NetBox version

v4.0-beta1

### Feature type

Change to existing functionality

### Proposed functionality

The proposal is to remove `staff_only=True` condition from Admin menu items.

Some additional changes will be required to ensure that a normal user (without Superuser access) does not see the Admin menu items where they don't have access anyway.

### Use case

Currently, if a Superuser has the Staff status removed, the user cannot access the Admin menu items anymore.

Discussed in #15733. Related comments also in the mainteners meeting minutes in #15089

### Database changes

None

### External dependencies

None


Discussion:
Some additional context:

- In NetBox v3.6, the UI views for managing users, groups, permissions, API tokens, and configuration revisions were moved from the "backend" Django admin UI to the primary UI.
- In NetBox v4.0, the remaining admin views were relocated to the primary UI, and the Django admin UI is disabled by default. (It can still be enabled for plugins which require it.)
- A custom user model was introduced in NetBox v4.0.

As our ultimate goal is to remove the Django admin UI from NetBox entirely, and as we now have the ability to customize fields on the user model, IMO we should drop the `is_staff` field entirely and rely on the permissions framework to control the display of individual navigation menu items.

Resolving patch:
diff --git a/netbox/netbox/navigation/menu.py b/netbox/netbox/navigation/menu.py
--- a/netbox/netbox/navigation/menu.py
+++ b/netbox/netbox/navigation/menu.py
@@ -368,12 +368,10 @@
         MenuGroup(
             label=_('Authentication'),
             items=(
-                # Proxy model for auth.User
                 MenuItem(
                     link=f'users:user_list',
                     link_text=_('Users'),
                     permissions=[f'auth.view_user'],
-                    staff_only=True,
                     buttons=(
                         MenuItemButton(
                             link=f'users:user_add',
@@ -389,12 +387,10 @@
                         )
                     )
                 ),
-                # Proxy model for auth.Group
                 MenuItem(
                     link=f'users:group_list',
                     link_text=_('Groups'),
                     permissions=[f'auth.view_group'],
-                    staff_only=True,
                     buttons=(
                         MenuItemButton(
                             link=f'users:group_add',
@@ -414,14 +410,12 @@
                     link=f'users:token_list',
                     link_text=_('API Tokens'),
                     permissions=[f'users.view_token'],
-                    staff_only=True,
                     buttons=get_model_buttons('users', 'token')
                 ),
                 MenuItem(
                     link=f'users:objectpermission_list',
                     link_text=_('Permissions'),
                     permissions=[f'users.view_objectpermission'],
-                    staff_only=True,
                     buttons=get_model_buttons('users', 'objectpermission', actions=['add'])
                 ),
             ),
@@ -432,14 +426,12 @@
                 MenuItem(
                     link='core:config',
                     link_text=_('Current Config'),
-                    permissions=['core.view_configrevision'],
-                    staff_only=True
+                    permissions=['core.view_configrevision']
                 ),
                 MenuItem(
                     link='core:configrevision_list',
                     link_text=_('Config Revisions'),
-                    permissions=['core.view_configrevision'],
-                    staff_only=True
+                    permissions=['core.view_configrevision']
                 ),
             ),
         ),
@@ -448,13 +440,11 @@
             items=(
                 MenuItem(
                     link='core:plugin_list',
-                    link_text=_('Plugins'),
-                    staff_only=True
+                    link_text=_('Plugins')
                 ),
                 MenuItem(
                     link='core:background_queue_list',
-                    link_text=_('Background Tasks'),
-                    staff_only=True
+                    link_text=_('Background Tasks')
                 ),
             ),
         ),
diff --git a/netbox/users/views.py b/netbox/users/views.py
--- a/netbox/users/views.py
+++ b/netbox/users/views.py
@@ -28,6 +28,7 @@ class TokenView(generic.ObjectView):
 class TokenEditView(generic.ObjectEditView):
     queryset = Token.objects.all()
     form = forms.TokenForm
+    template_name = 'users/token_edit.html'
 
 
 @register_model_view(Token, 'delete')


Test patch: