This commit is contained in:
Timothy Jaeryang Baek committed 2026-06-17 00:33:30 +02:00
1 parent 0726db7217
commit edf3ae9209
6 files changed
+49 -15

No files matched your search

+3
View File
@@ -2768,6 +2768,8 @@ USER_PERMISSIONS_CHAT_ALLOW_PUBLIC_SHARING = (
USER_PERMISSIONS_CHAT_EXPORT = os.getenv('USER_PERMISSIONS_CHAT_EXPORT', 'True').lower() == 'true'
USER_PERMISSIONS_CHAT_IMPORT = os.getenv('USER_PERMISSIONS_CHAT_IMPORT', 'True').lower() == 'true'
USER_PERMISSIONS_CHAT_STT = os.getenv('USER_PERMISSIONS_CHAT_STT', 'True').lower() == 'true'
USER_PERMISSIONS_CHAT_TTS = os.getenv('USER_PERMISSIONS_CHAT_TTS', 'True').lower() == 'true'
@@ -2864,6 +2866,7 @@ DEFAULT_USER_PERMISSIONS = {
'edit': USER_PERMISSIONS_CHAT_EDIT,
'share': USER_PERMISSIONS_CHAT_SHARE,
'export': USER_PERMISSIONS_CHAT_EXPORT,
'import': USER_PERMISSIONS_CHAT_IMPORT,
'stt': USER_PERMISSIONS_CHAT_STT,
'tts': USER_PERMISSIONS_CHAT_TTS,
'call': USER_PERMISSIONS_CHAT_CALL,
+9
View File
@@ -585,10 +585,19 @@ async def create_new_chat(
@router.post('/import', response_model=list[ChatResponse])
async def import_chats(
request: Request,
form_data: ChatsImportForm,
user=Depends(get_verified_user),
db: AsyncSession = Depends(get_async_session),
):
if user.role != 'admin' and not await has_permission(
user.id, 'chat.import', request.app.state.config.USER_PERMISSIONS, db=db
):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=ERROR_MESSAGES.ACCESS_PROHIBITED,
)
try:
chats = await Chats.import_chats(user.id, form_data.chats, db=db)
return chats
+5 -2
View File
@@ -38,7 +38,7 @@ from open_webui.utils.auth import (
get_verified_user,
validate_password,
)
from pydantic import BaseModel, ConfigDict
from pydantic import BaseModel, ConfigDict, Field
from sqlalchemy.ext.asyncio import AsyncSession
log = logging.getLogger(__name__)
@@ -201,6 +201,8 @@ class AccessGrantsPermissions(BaseModel):
class ChatPermissions(BaseModel):
model_config = ConfigDict(populate_by_name=True)
controls: bool = True
valves: bool = True
system_prompt: bool = True
@@ -215,6 +217,7 @@ class ChatPermissions(BaseModel):
edit: bool = True
share: bool = True
export: bool = True
import_: bool = Field(default=True, alias='import')
stt: bool = True
tts: bool = True
call: bool = True
@@ -265,7 +268,7 @@ async def get_default_user_permissions(request: Request, user=Depends(get_admin_
@router.post('/default/permissions')
async def update_default_user_permissions(request: Request, form_data: UserPermissions, user=Depends(get_admin_user)):
request.app.state.config.USER_PERMISSIONS = form_data.model_dump()
request.app.state.config.USER_PERMISSIONS = form_data.model_dump(by_alias=True)
return request.app.state.config.USER_PERMISSIONS