Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support auth_required in PluginMenuItem #18529

Open
bctiemann opened this issue Jan 29, 2025 · 0 comments · May be fixed by #18530
Open

Support auth_required in PluginMenuItem #18529

bctiemann opened this issue Jan 29, 2025 · 0 comments · May be fixed by #18530
Assignees
Labels
complexity: low Requires minimal effort to implement status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application

Comments

@bctiemann
Copy link
Contributor

NetBox version

v4.2.2

Feature type

New functionality

Proposed functionality

At present the PluginMenuItem class is missing the auth_required attribute which is present on all regular MenuItems, and which is necessary for controlling whether the plugin's menu items appear in the nav menu. This attribute needs to be defined with a default of False.

Use case

This is necessary because of this code:

for menu in MENUS:
groups = []
for group in menu.groups:
items = []
for item in group.items:
if getattr(item, 'auth_required', False) and not user.is_authenticated:
continue
if not user.has_perms(item.permissions):

Which is what determines whether a menu item is shown in the nav menu. Because auth_required is not present on PluginMenuItem, the check on L29 evaluates to False and the menu item is shown regardless of authentication state.

Database changes

N/A

External dependencies

N/A

@bctiemann bctiemann added status: needs triage This issue is awaiting triage by a maintainer type: feature Introduction of new functionality to the application labels Jan 29, 2025
@bctiemann bctiemann self-assigned this Jan 29, 2025
@bctiemann bctiemann added status: accepted This issue has been accepted for implementation complexity: low Requires minimal effort to implement and removed status: needs triage This issue is awaiting triage by a maintainer labels Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity: low Requires minimal effort to implement status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant