Repository navigation
Description
Summary
The Nevermined payment configuration endpoints use can_user_share_agent (owner-only permission) for ALL operations, including viewing config. Users who have an agent shared with them get 403 on every request — the GET on page load, the POST to save, and all other operations. From the user's perspective, the Save button appears to do nothing (the error notification is easy to miss).
Component
Backend / Nevermined Router + Frontend / NeverminedPanel
Priority
P2 - Feature impaired for shared users, owner/admin can still configure.
Error
HTTP 403 {"detail":"Owner access required"}
All requests to /api/nevermined/agents/{name}/config return 403 for shared (non-owner) users.
Location
- File:
src/backend/routers/nevermined.py - Lines: 26-31
- Function:
_require_agent_access()
Root Cause
The _require_agent_access helper uses db.can_user_share_agent() which only allows owners and admins — it does NOT check if the agent is shared with the user. This is more restrictive than other agent endpoints.
For comparison:
- Agent detail, logs, chat, terminal — use
can_user_access_agent()(includes shared users) ✅ - Agent sharing, rename — use
can_user_share_agent()(owner-only) — appropriate for destructive ops ✅ - Nevermined config (all ops) — uses
can_user_share_agent()(owner-only) ❌ — too restrictive for viewing config
Additionally, the frontend NeverminedPanel.vue doesn't clearly communicate the 403 failure:
- On page load, GET returns 403 → shows a brief "Failed to load Nevermined config" notification but still renders the empty form
- On save, POST returns 403 → shows "Owner access required" notification, but user may miss it since the form stays unchanged
Reproduction Steps
- Create an agent as admin
- Share that agent with another user (email auth)
- Log in as the shared user
- Navigate to the agent's Payments tab
- Fill in all Nevermined fields (API Key, Agent ID, Plan ID)
- Click "Save Configuration"
- Nothing visibly happens — the request returns 403, a subtle notification appears briefly
Suggested Fix
Backend — Use appropriate permission levels in _require_agent_access:
# Option A: Allow shared users to view, only owners can modify
def _require_agent_access(agent_name: str, current_user: User, write: bool = False):
"""Verify the user has appropriate access to the agent."""
if current_user.role == "admin":
return
if write:
if not db.can_user_share_agent(current_user.username, agent_name):
raise HTTPException(status_code=403, detail="Owner access required")
else:
if not db.can_user_access_agent(current_user.username, agent_name):
raise HTTPException(status_code=403, detail="Access denied")
# Then use write=True for POST/PUT/DELETE, write=False for GET# Option B: Simply allow all shared users (simpler)
def _require_agent_access(agent_name: str, current_user: User):
if current_user.role == "admin":
return
if not db.can_user_access_agent(current_user.username, agent_name):
raise HTTPException(status_code=403, detail="Access denied")Frontend — Make 403 errors more visible in NeverminedPanel.vue:
// In loadConfig() catch block, show a persistent/clear message for 403
catch (err) {
if (err.response?.status === 403) {
permissionError.value = 'You need owner access to configure payments for this agent.'
} else if (err.response?.status !== 404) {
showNotification('Failed to load Nevermined config', 'error')
}
config.value = null
}Environment
- Trinity version:
f50ee3e
Related
src/backend/routers/nevermined.py— all endpoints use_require_agent_accesswith owner-only checksrc/backend/db/agents.py:278—can_user_share_agent(owner-only)src/backend/db/agents.py:114—can_user_access_agent(includes shared users)src/frontend/src/components/NeverminedPanel.vue— error handling inloadConfig()andsaveConfig()
Activity
AndriiPasternak31 commentedon Mar 27, 2026
This bug was already fixed in commit f1dfd7d (2026-03-05). The fix split Nevermined endpoint permissions into read/write access levels:
_require_read_access(GET endpoints) usescan_user_access_agent— allows shared users to view config and payment history._require_write_access(POST/PUT/DELETE) usescan_user_share_agent— owner-only for modifications.NeverminedPanel.vueacceptscanEditprop, shows read-only notice banner for shared users, disables form inputs, and hides action buttons.tests/test_nevermined_permissions.pycovers owner CRUD, unauthenticated rejection, and nonexistent agent checks.AndriiPasternak31 commentedon Mar 27, 2026
This bug was already fixed in commit f1dfd7d (2026-03-05). The fix split Nevermined endpoint permissions into read/write access levels:
_require_read_access(GET endpoints) usescan_user_access_agent— allows shared users to view config and payment history._require_write_access(POST/PUT/DELETE) usescan_user_share_agent— owner-only for modifications.NeverminedPanel.vueacceptscanEditprop, shows read-only notice banner for shared users, disables form inputs, and hides action buttons.tests/test_nevermined_permissions.pycovers owner CRUD, unauthenticated rejection, and nonexistent agent checks.This issue can be closed.
fix(brain-orb): preserve selection across refresh + validate link end…