diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py
index bd977bdc6..b597050dc 100644
--- a/backend/open_webui/config.py
+++ b/backend/open_webui/config.py
@@ -1068,6 +1068,14 @@ USER_PERMISSIONS_CHAT_EDIT = (
os.environ.get("USER_PERMISSIONS_CHAT_EDIT", "True").lower() == "true"
)
+USER_PERMISSIONS_CHAT_SHARE = (
+ os.environ.get("USER_PERMISSIONS_CHAT_SHARE", "True").lower() == "true"
+)
+
+USER_PERMISSIONS_CHAT_EXPORT = (
+ os.environ.get("USER_PERMISSIONS_CHAT_EXPORT", "True").lower() == "true"
+)
+
USER_PERMISSIONS_CHAT_STT = (
os.environ.get("USER_PERMISSIONS_CHAT_STT", "True").lower() == "true"
)
@@ -1132,6 +1140,8 @@ DEFAULT_USER_PERMISSIONS = {
"file_upload": USER_PERMISSIONS_CHAT_FILE_UPLOAD,
"delete": USER_PERMISSIONS_CHAT_DELETE,
"edit": USER_PERMISSIONS_CHAT_EDIT,
+ "share": USER_PERMISSIONS_CHAT_SHARE,
+ "export": USER_PERMISSIONS_CHAT_EXPORT,
"stt": USER_PERMISSIONS_CHAT_STT,
"tts": USER_PERMISSIONS_CHAT_TTS,
"call": USER_PERMISSIONS_CHAT_CALL,
diff --git a/backend/open_webui/routers/chats.py b/backend/open_webui/routers/chats.py
index 5fd44ab9f..6f00dd4d7 100644
--- a/backend/open_webui/routers/chats.py
+++ b/backend/open_webui/routers/chats.py
@@ -638,8 +638,17 @@ async def archive_chat_by_id(id: str, user=Depends(get_verified_user)):
@router.post("/{id}/share", response_model=Optional[ChatResponse])
-async def share_chat_by_id(id: str, user=Depends(get_verified_user)):
+async def share_chat_by_id(request: Request, id: str, user=Depends(get_verified_user)):
+ if not has_permission(
+ user.id, "chat.share", request.app.state.config.USER_PERMISSIONS
+ ):
+ raise HTTPException(
+ status_code=status.HTTP_401_UNAUTHORIZED,
+ detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
+ )
+
chat = Chats.get_chat_by_id_and_user_id(id, user.id)
+
if chat:
if chat.share_id:
shared_chat = Chats.update_shared_chat_by_chat_id(chat.id)
diff --git a/backend/open_webui/routers/users.py b/backend/open_webui/routers/users.py
index a6c2c90c4..29638199e 100644
--- a/backend/open_webui/routers/users.py
+++ b/backend/open_webui/routers/users.py
@@ -88,6 +88,8 @@ class ChatPermissions(BaseModel):
file_upload: bool = True
delete: bool = True
edit: bool = True
+ share: bool = True
+ export: bool = True
stt: bool = True
tts: bool = True
call: bool = True
diff --git a/src/lib/components/admin/Users/Groups.svelte b/src/lib/components/admin/Users/Groups.svelte
index dce8423e5..36c1014ba 100644
--- a/src/lib/components/admin/Users/Groups.svelte
+++ b/src/lib/components/admin/Users/Groups.svelte
@@ -63,6 +63,8 @@
file_upload: true,
delete: true,
edit: true,
+ share: true,
+ export: true,
stt: true,
tts: true,
call: true,
diff --git a/src/lib/components/admin/Users/Groups/Permissions.svelte b/src/lib/components/admin/Users/Groups/Permissions.svelte
index c7a1308a5..9edf20ca0 100644
--- a/src/lib/components/admin/Users/Groups/Permissions.svelte
+++ b/src/lib/components/admin/Users/Groups/Permissions.svelte
@@ -24,6 +24,8 @@
file_upload: true,
delete: true,
edit: true,
+ share: true,
+ export: true,
stt: true,
tts: true,
call: true,
@@ -276,6 +278,22 @@