mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
parent
0d633c0d17
commit
01472c071b
5 changed files with 23 additions and 7 deletions
|
|
@ -33,7 +33,7 @@ from utils.utils import (
|
||||||
from utils.misc import parse_duration, validate_email_format
|
from utils.misc import parse_duration, validate_email_format
|
||||||
from utils.webhook import post_webhook
|
from utils.webhook import post_webhook
|
||||||
from constants import ERROR_MESSAGES, WEBHOOK_MESSAGES
|
from constants import ERROR_MESSAGES, WEBHOOK_MESSAGES
|
||||||
from config import WEBUI_AUTH_TRUSTED_EMAIL_HEADER
|
from config import WEBUI_AUTH, WEBUI_AUTH_TRUSTED_EMAIL_HEADER
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
@ -118,6 +118,19 @@ async def signin(request: Request, form_data: SigninForm):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
user = Auths.authenticate_user_by_trusted_header(trusted_email)
|
user = Auths.authenticate_user_by_trusted_header(trusted_email)
|
||||||
|
|
||||||
|
if WEBUI_AUTH == False:
|
||||||
|
admin_email = "admin@localhost"
|
||||||
|
admin_password = "admin"
|
||||||
|
|
||||||
|
if Users.get_num_users() == 0 and not Users.get_user_by_email(
|
||||||
|
admin_email.lower()
|
||||||
|
):
|
||||||
|
await signup(
|
||||||
|
request,
|
||||||
|
SignupForm(email=admin_email, password=admin_password, name="User"),
|
||||||
|
)
|
||||||
|
user = Auths.authenticate_user(admin_email.lower(), admin_password)
|
||||||
else:
|
else:
|
||||||
user = Auths.authenticate_user(form_data.email.lower(), form_data.password)
|
user = Auths.authenticate_user(form_data.email.lower(), form_data.password)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -413,7 +413,7 @@ WEBUI_VERSION = os.environ.get("WEBUI_VERSION", "v1.0.0-alpha.100")
|
||||||
# WEBUI_AUTH (Required for security)
|
# WEBUI_AUTH (Required for security)
|
||||||
####################################
|
####################################
|
||||||
|
|
||||||
WEBUI_AUTH = True
|
WEBUI_AUTH = os.environ.get("WEBUI_AUTH", "True").lower() == "true"
|
||||||
WEBUI_AUTH_TRUSTED_EMAIL_HEADER = os.environ.get(
|
WEBUI_AUTH_TRUSTED_EMAIL_HEADER = os.environ.get(
|
||||||
"WEBUI_AUTH_TRUSTED_EMAIL_HEADER", None
|
"WEBUI_AUTH_TRUSTED_EMAIL_HEADER", None
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ from config import (
|
||||||
CONFIG_DATA,
|
CONFIG_DATA,
|
||||||
WEBUI_NAME,
|
WEBUI_NAME,
|
||||||
WEBUI_URL,
|
WEBUI_URL,
|
||||||
|
WEBUI_AUTH,
|
||||||
ENV,
|
ENV,
|
||||||
VERSION,
|
VERSION,
|
||||||
CHANGELOG,
|
CHANGELOG,
|
||||||
|
|
@ -240,6 +241,7 @@ async def get_app_config():
|
||||||
"status": True,
|
"status": True,
|
||||||
"name": WEBUI_NAME,
|
"name": WEBUI_NAME,
|
||||||
"version": VERSION,
|
"version": VERSION,
|
||||||
|
"auth": WEBUI_AUTH,
|
||||||
"default_locale": default_locale,
|
"default_locale": default_locale,
|
||||||
"images": images_app.state.ENABLED,
|
"images": images_app.state.ENABLED,
|
||||||
"default_models": webui_app.state.DEFAULT_MODELS,
|
"default_models": webui_app.state.DEFAULT_MODELS,
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,10 @@ def calculate_sha256_string(string):
|
||||||
|
|
||||||
|
|
||||||
def validate_email_format(email: str) -> bool:
|
def validate_email_format(email: str) -> bool:
|
||||||
if not re.match(r"[^@]+@[^@]+\.[^@]+", email):
|
if email.endswith("@localhost"):
|
||||||
return False
|
return True
|
||||||
return True
|
|
||||||
|
return bool(re.match(r"[^@]+@[^@]+\.[^@]+", email))
|
||||||
|
|
||||||
|
|
||||||
def sanitize_filename(file_name):
|
def sanitize_filename(file_name):
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@
|
||||||
await goto('/');
|
await goto('/');
|
||||||
}
|
}
|
||||||
loaded = true;
|
loaded = true;
|
||||||
if ($config?.trusted_header_auth ?? false) {
|
if (($config?.trusted_header_auth ?? false) || $config?.auth === false) {
|
||||||
await signInHandler();
|
await signInHandler();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -97,7 +97,7 @@
|
||||||
</div> -->
|
</div> -->
|
||||||
|
|
||||||
<div class="w-full sm:max-w-md px-10 min-h-screen flex flex-col text-center">
|
<div class="w-full sm:max-w-md px-10 min-h-screen flex flex-col text-center">
|
||||||
{#if $config?.trusted_header_auth ?? false}
|
{#if ($config?.trusted_header_auth ?? false) || $config?.auth === false}
|
||||||
<div class=" my-auto pb-10 w-full">
|
<div class=" my-auto pb-10 w-full">
|
||||||
<div
|
<div
|
||||||
class="flex items-center justify-center gap-3 text-xl sm:text-2xl text-center font-bold dark:text-gray-200"
|
class="flex items-center justify-center gap-3 text-xl sm:text-2xl text-center font-bold dark:text-gray-200"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue