A nav item says which permission its page needs
The sidebar hides what the caller cannot reach - that is what makes it useful to a guest, and what stops a member with a sparse role being offered links that can only answer 403. It reads the permission off the nav item to decide. Only four items ever declared one. Machines, PCs, Printers, Network, USB, Knowledge Base, Notifications, Calendar, Dashboard, Map, Applications and Reports declared nothing, so the filter had nothing to go on: granting the guest role machines.view opened the API and left the sidebar empty, which reads as the grant not working. Every item now names its read permission - in the plugins, in the core navigation endpoint, and in the frontend's fallback list, which is what renders when the endpoint is unreachable and would otherwise disagree with it.
This commit is contained in:
@@ -155,9 +155,14 @@ def get_navigation():
|
||||
all_items = []
|
||||
|
||||
# Core navigation items (always present)
|
||||
# Every item names the permission its page needs, so the filter below can
|
||||
# hide what the caller cannot reach - a link that only leads to a 401 is
|
||||
# worse than no link.
|
||||
all_items.extend([
|
||||
{'name': 'Dashboard', 'icon': 'layout-dashboard', 'route': '/', 'position': 0},
|
||||
{'name': 'Map', 'icon': 'map', 'route': '/map', 'position': 4},
|
||||
{'name': 'Dashboard', 'icon': 'layout-dashboard', 'route': '/',
|
||||
'position': 0, 'permission': 'assets.view'},
|
||||
{'name': 'Map', 'icon': 'map', 'route': '/map', 'position': 4,
|
||||
'permission': 'assets.view'},
|
||||
])
|
||||
|
||||
# Collect navigation items from enabled plugins. Disabling persists to the
|
||||
@@ -181,8 +186,11 @@ def get_navigation():
|
||||
|
||||
# Add core information section items
|
||||
all_items.extend([
|
||||
{'name': 'Applications', 'icon': 'app-window', 'route': '/applications', 'position': 30, 'section': 'information'},
|
||||
{'name': 'Reports', 'icon': 'bar-chart-3', 'route': '/reports', 'position': 40, 'section': 'information'},
|
||||
{'name': 'Applications', 'icon': 'app-window', 'route': '/applications',
|
||||
'position': 30, 'section': 'information',
|
||||
'permission': 'applications.view'},
|
||||
{'name': 'Reports', 'icon': 'bar-chart-3', 'route': '/reports',
|
||||
'position': 40, 'section': 'information', 'permission': 'reports.view'},
|
||||
])
|
||||
|
||||
# Sort by position
|
||||
|
||||
Reference in New Issue
Block a user