Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
open-webui
Commits
01472c07
Commit
01472c07
authored
May 08, 2024
by
Timothy J. Baek
Browse files
feat: support webui_auth false
#929
parent
0d633c0d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
7 deletions
+23
-7
backend/apps/web/routers/auths.py
backend/apps/web/routers/auths.py
+14
-1
backend/config.py
backend/config.py
+1
-1
backend/main.py
backend/main.py
+2
-0
backend/utils/misc.py
backend/utils/misc.py
+4
-3
src/routes/auth/+page.svelte
src/routes/auth/+page.svelte
+2
-2
No files found.
backend/apps/web/routers/auths.py
View file @
01472c07
...
...
@@ -33,7 +33,7 @@ from utils.utils import (
from
utils.misc
import
parse_duration
,
validate_email_format
from
utils.webhook
import
post_webhook
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
()
...
...
@@ -118,6 +118,19 @@ async def signin(request: Request, form_data: SigninForm):
),
)
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
:
user
=
Auths
.
authenticate_user
(
form_data
.
email
.
lower
(),
form_data
.
password
)
...
...
backend/config.py
View file @
01472c07
...
...
@@ -413,7 +413,7 @@ WEBUI_VERSION = os.environ.get("WEBUI_VERSION", "v1.0.0-alpha.100")
# 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"
,
None
)
...
...
backend/main.py
View file @
01472c07
...
...
@@ -44,6 +44,7 @@ from config import (
CONFIG_DATA
,
WEBUI_NAME
,
WEBUI_URL
,
WEBUI_AUTH
,
ENV
,
VERSION
,
CHANGELOG
,
...
...
@@ -240,6 +241,7 @@ async def get_app_config():
"status"
:
True
,
"name"
:
WEBUI_NAME
,
"version"
:
VERSION
,
"auth"
:
WEBUI_AUTH
,
"default_locale"
:
default_locale
,
"images"
:
images_app
.
state
.
ENABLED
,
"default_models"
:
webui_app
.
state
.
DEFAULT_MODELS
,
...
...
backend/utils/misc.py
View file @
01472c07
...
...
@@ -38,9 +38,10 @@ def calculate_sha256_string(string):
def
validate_email_format
(
email
:
str
)
->
bool
:
if
not
re
.
match
(
r
"[^@]+@[^@]+\.[^@]+"
,
email
):
return
False
return
True
if
email
.
endswith
(
"@localhost"
):
return
True
return
bool
(
re
.
match
(
r
"[^@]+@[^@]+\.[^@]+"
,
email
))
def
sanitize_filename
(
file_name
):
...
...
src/routes/auth/+page.svelte
View file @
01472c07
...
...
@@ -60,7 +60,7 @@
await goto('/');
}
loaded = true;
if ($config?.trusted_header_auth ?? false) {
if
(
($config?.trusted_header_auth ?? false)
|| $config?.auth === false)
{
await signInHandler();
}
});
...
...
@@ -97,7 +97,7 @@
</div> -->
<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="flex items-center justify-center gap-3 text-xl sm:text-2xl text-center font-bold dark:text-gray-200"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment