[Bug] Storage action bar (Upload / From URL / Templates / Rescan) is gated on role === 'admin' instead of the storage.* permissions
Summary
In the datastore detail view, the entire action bar — Templates, From URL, Upload and Rescan — is rendered only for users whose role is literally admin. The corresponding API endpoints are guarded by fine-grained storage.* permissions instead (see the table below). As a result those permissions cannot be used through the UI: a non-admin user who holds storage.upload would be authorised by the backend, but never gets a control to click.
Environment
- PegaProx 1.0 (
ghcr.io/pegaprox/pegaprox:1.0, Docker Swarm, behind a reverse proxy) - Authentication: OIDC (Microsoft Entra ID)
- Affected user: custom tenant-scoped role based on the Tenant Operator template, with
storage.view,storage.uploadandstorage.downloadgranted
Steps to reproduce
- Create a tenant and assign one cluster to it.
- Create a custom role scoped to that tenant, including
storage.upload(e.g. from the Tenant Operator template). - Assign that role to a user and log in as them.
- Open the datastore view and select a storage that has
isoin its content types.
Expected: the Upload and From URL buttons are available, because the user holds storage.upload.
Actual: the action bar is not rendered at all — no Upload, no From URL, no Templates, no Rescan. Opening the same storage as a user with the admin role shows the full action bar.
Root cause
Code references below are from tag v1.0 (build 2026.08.01).
web/src/storage.js:1539:
{selectedStorage && isAdmin && (
<div className="flex gap-2">
{/* Templates, From URL, Upload, Rescan — each with its own content-type check */}
isAdmin comes from the auth context and is a plain role comparison, not a permission check — web/src/contexts.js:450:
isAdmin: user?.role === 'admin'
The per-button conditions nested inside only test the storage content type (canUploadTo at storage.js:935, content.includes('vztmpl'), …), so no permission is ever consulted.
Meanwhile the backend enforces exactly the right permissions:
| UI control | Endpoint | Required permission | Source |
|---|---|---|---|
| Upload | POST /api/clusters/<id>/datastores/<storage>/upload |
storage.upload |
pegaprox/api/vms.py:1049 |
| From URL | POST /api/clusters/<id>/datastores/<storage>/download-url |
storage.upload |
pegaprox/api/vms.py:1220 |
| Templates | POST /api/clusters/<id>/templates/download |
storage.download |
pegaprox/api/storage.py:2111 |
| Rescan | POST /api/clusters/<id>/datacenter/storage/<storage_id>/rescan |
storage.config |
pegaprox/api/storage.py:1631 |
Impact
There is no way to grant ISO upload through the UI to any non-admin user. Promoting the user to admin is not a viable workaround.
This makes storage.upload effectively dead in the UI, even though it ships as part of the built-in user role and several role templates (Tenant Administrator, Tenant Operator, Storage Administrator, …).
Suggested fix
Gate each control on the permission its endpoint already requires, instead of on the role. The data is already available client-side — the login payload returns effective permissions for exactly this purpose (pegaprox/api/auth.py:845):
'permissions': get_user_permissions(user), # LW: Frontend can hide/show buttons
and the codebase already uses this idiom for the main tab strip (web/src/dashboard.js:14901):
const can = (p) => user?.role === 'admin' || (Array.isArray(user?.permissions) && user.permissions.includes(p));
Applying can('storage.upload') / can('storage.download') / can('storage.config') to the individual buttons — and dropping the outer isAdmin — would make the UI consistent with the API and keep admins unaffected.
Related
web/src/storage.js contains several further isAdmin gates (around lines 1392, 1417, 1624, 1653, 1697, 1730, 1847) which may hide other permission-backed actions from users who are entitled to them. A sweep of that file may be worthwhile alongside this fix.
👋 Thanks for reporting a bug!
Unfortunately, it looks like some required information is missing.
Please provide:
- [ ] Describe the bug
- [ ] PegaProx Version
Why? We are volunteers maintaining PegaProx in our free time. Complete bug reports help us fix issues faster. 🐾
Closing for now — please reopen with the required details or open a new issue.
This is an automated message.