enh: access grant level perms

This commit is contained in:
Timothy Jaeryang Baek
2026-02-23 15:49:05 -06:00
parent a52e6c2d57
commit 3d99de6771
22 changed files with 201 additions and 8 deletions
+13 -1
View File
@@ -21,7 +21,7 @@ from open_webui.models.tools import (
ToolAccessResponse,
Tools,
)
from open_webui.models.access_grants import AccessGrants, has_public_read_access_grant
from open_webui.models.access_grants import AccessGrants, has_public_read_access_grant, has_user_access_grant, strip_user_access_grants
from open_webui.utils.plugin import (
load_tool_module_by_id,
replace_imports,
@@ -595,6 +595,18 @@ async def update_tool_access_by_id(
)
]
# Strip individual user sharing if user lacks permission
if (
user.role != "admin"
and has_user_access_grant(form_data.access_grants)
and not has_permission(
user.id,
"access_grants.allow_users",
request.app.state.config.USER_PERMISSIONS,
)
):
form_data.access_grants = strip_user_access_grants(form_data.access_grants)
AccessGrants.set_access_grants("tool", id, form_data.access_grants, db=db)
return Tools.get_tool_by_id(id, db=db)