netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
16.35k stars 2.6k forks source link

Hide Admin menu section for non-admins #17010

Open alehaa opened 3 months ago

alehaa commented 3 months ago

NetBox version

v4.0.8

Feature type

Change to existing functionality

Proposed functionality

If a user is not an administrator, the Admin > System section of the menu should not be visible. If the user also lacks permissions for any menu item of Admin > Authentication, the Admin section should be hidden completely.

Use case

A user with no permissions can't see API Tokens, System and Background Tasks. However, these menu items are shown. Hiding them makes the UI a bit cleaner.

Database changes

None

External dependencies

None

alehaa commented 2 months ago

I volunteer to work on a PR for this feature.

jhofmueller commented 1 month ago

Any news on this one? I hesitate to upgrade from 3.7.8 because I do not want to confuse our users. Stating that I have to add that this behavior was introduced in the 4.x branch.

wz4 commented 2 weeks ago

This looks like it can be handled by assigning each MenuItem the attribute staff_only=True

https://github.com/netbox-community/netbox/blob/fe0ae39903f96e76f94d61ab7fb937980e861c4a/netbox/netbox/navigation/menu.py#L381-L393

jhofmueller commented 2 weeks ago

Thank you, but no. I don't want to mess with the code on our installation. I have avoided running NetBox from a dedicated code base (aka our own) so far and would like to stick to that. So I'm still hoping for the old behavior to be restored :sunglasses:

wz4 commented 1 week ago

@arthanson I will volunterr unless @alehaa is still interested.

alehaa commented 1 week ago

@wz4 you can take this one but I still volunteer as backup.

Please keep in mind there are plans to remove the staff field in #16137, checking the admin state would be preferable.