[Bug] Storage action bar (Upload / From URL / Templates / Rescan) is gated on role === 'admin' instead of the storage.* permissions
Describe the bug
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. There is no way to grant ISO upload to a non-admin user.
Code references below are from tag v1.0 (build 2026.08.01).
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.
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.
Expected behavior
The Upload and From URL buttons should be available, because the user holds storage.upload — the permission the API itself requires for those operations.
Environment
- PegaProx Version: 1.0
- Installation Method: Docker (
ghcr.io/pegaprox/pegaprox, Docker Swarm) - OS: Debian 12
- Browser: Google Chrome
- Behind Reverse Proxy? nginx-proxy
- UI? Corporate
Logs
Not applicable — no request is made and nothing is logged. The controls are never rendered client-side.
Root cause
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
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.
Checklist
- [x] I have searched existing issues to make sure this is not a duplicate
- [x] I am using the latest version of PegaProx
Yep, confirmed. That bar (Templates / From URL / Upload / Rescan) sits behind a plain isAdmin check in storage.js, while the endpoints themselves are on the storage.* perms — so a non-admin holding e.g. storage.config gets no button for something the backend would happily allow. It's part of a pile of old hardcoded-admin gates we've been moving over to real perms; noted, we'll wire this one to the storage.* checks.
btw PegaProx runs on community funding — a bit on https://opencollective.com/pegaprox helps us keep chipping away 💚
Fixed in v1.0.1 — the storage action bar (Upload / From URL / Templates / Rescan) now follows the storage.* backend permissions instead of a blanket admin check. Thanks for flagging it.