feat: enable OAuth signup configuration for signout functionality

This commit is contained in:
Zaiban Ali 2024-12-07 15:21:05 +01:00
parent 9918ec6246
commit 48d604a525
2 changed files with 19 additions and 18 deletions

View File

@ -33,6 +33,7 @@ from fastapi import APIRouter, Depends, HTTPException, Request, status
from fastapi.responses import RedirectResponse, Response from fastapi.responses import RedirectResponse, Response
from open_webui.config import ( from open_webui.config import (
OPENID_PROVIDER_URL, OPENID_PROVIDER_URL,
ENABLE_OAUTH_SIGNUP,
) )
from pydantic import BaseModel from pydantic import BaseModel
from open_webui.utils.misc import parse_duration, validate_email_format from open_webui.utils.misc import parse_duration, validate_email_format
@ -505,6 +506,7 @@ async def signup(request: Request, response: Response, form_data: SignupForm):
async def signout(request: Request, response: Response): async def signout(request: Request, response: Response):
response.delete_cookie("token") response.delete_cookie("token")
if ENABLE_OAUTH_SIGNUP.value:
id_token = request.cookies.get("id_token", None) id_token = request.cookies.get("id_token", None)
if id_token: if id_token:
async with httpx.AsyncClient() as client: async with httpx.AsyncClient() as client:

View File

@ -20,7 +20,6 @@ from open_webui.config import (
OAUTH_MERGE_ACCOUNTS_BY_EMAIL, OAUTH_MERGE_ACCOUNTS_BY_EMAIL,
OAUTH_PROVIDERS, OAUTH_PROVIDERS,
ENABLE_OAUTH_ROLE_MANAGEMENT, ENABLE_OAUTH_ROLE_MANAGEMENT,
OAUTH_PROVIDER_NAME,
OAUTH_ROLES_CLAIM, OAUTH_ROLES_CLAIM,
OAUTH_EMAIL_CLAIM, OAUTH_EMAIL_CLAIM,
OAUTH_PICTURE_CLAIM, OAUTH_PICTURE_CLAIM,
@ -254,7 +253,7 @@ class OAuthManager:
secure=WEBUI_SESSION_COOKIE_SECURE, secure=WEBUI_SESSION_COOKIE_SECURE,
) )
if OAUTH_PROVIDER_NAME.value: if ENABLE_OAUTH_SIGNUP.value:
id_token = token.get("id_token") id_token = token.get("id_token")
response.set_cookie( response.set_cookie(
key="id_token", key="id_token",