mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-11 08:57:17 +00:00
feat: add OAuth persistent configuration check to admin routes
Prevents a user from changeing OAUTH settins in UI when they arent persistenct to imporve UX and clarity
This commit is contained in:
parent
8dbbc206c5
commit
f7f91748f3
1 changed files with 10 additions and 0 deletions
|
|
@ -1440,13 +1440,23 @@ def oauth_config_updates(data: dict) -> dict:
|
|||
}
|
||||
|
||||
|
||||
def _require_oauth_persistent_config():
|
||||
if not Config.OAUTH_PERSISTENT_ENABLED:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail='OAuth admin configuration is disabled. Set ENABLE_OAUTH_PERSISTENT_CONFIG=true to enable.',
|
||||
)
|
||||
|
||||
|
||||
@router.get('/admin/config/oauth', response_model=OAuthConfigForm)
|
||||
async def get_oauth_config(request: Request, user=Depends(get_admin_user)):
|
||||
_require_oauth_persistent_config()
|
||||
return await get_oauth_config_values()
|
||||
|
||||
|
||||
@router.post('/admin/config/oauth', response_model=OAuthConfigForm)
|
||||
async def update_oauth_config(request: Request, form_data: OAuthConfigForm, user=Depends(get_admin_user)):
|
||||
_require_oauth_persistent_config()
|
||||
await Config.upsert(oauth_config_updates(form_data.model_dump(exclude_none=True)))
|
||||
return await get_oauth_config_values()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue