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
f3bd8107
Unverified
Commit
f3bd8107
authored
Jun 16, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Jun 16, 2024
Browse files
Merge pull request #3202 from JohnTheNerd/main
feat: added ability to set user name for federated auth
parents
6d9ed329
c00a6fa0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
2 deletions
+10
-2
backend/apps/webui/main.py
backend/apps/webui/main.py
+2
-0
backend/apps/webui/routers/auths.py
backend/apps/webui/routers/auths.py
+5
-2
backend/config.py
backend/config.py
+3
-0
No files found.
backend/apps/webui/main.py
View file @
f3bd8107
...
@@ -25,6 +25,7 @@ from config import (
...
@@ -25,6 +25,7 @@ from config import (
USER_PERMISSIONS
,
USER_PERMISSIONS
,
WEBHOOK_URL
,
WEBHOOK_URL
,
WEBUI_AUTH_TRUSTED_EMAIL_HEADER
,
WEBUI_AUTH_TRUSTED_EMAIL_HEADER
,
WEBUI_AUTH_TRUSTED_NAME_HEADER
,
JWT_EXPIRES_IN
,
JWT_EXPIRES_IN
,
WEBUI_BANNERS
,
WEBUI_BANNERS
,
ENABLE_COMMUNITY_SHARING
,
ENABLE_COMMUNITY_SHARING
,
...
@@ -40,6 +41,7 @@ app.state.config = AppConfig()
...
@@ -40,6 +41,7 @@ app.state.config = AppConfig()
app
.
state
.
config
.
ENABLE_SIGNUP
=
ENABLE_SIGNUP
app
.
state
.
config
.
ENABLE_SIGNUP
=
ENABLE_SIGNUP
app
.
state
.
config
.
JWT_EXPIRES_IN
=
JWT_EXPIRES_IN
app
.
state
.
config
.
JWT_EXPIRES_IN
=
JWT_EXPIRES_IN
app
.
state
.
AUTH_TRUSTED_EMAIL_HEADER
=
WEBUI_AUTH_TRUSTED_EMAIL_HEADER
app
.
state
.
AUTH_TRUSTED_EMAIL_HEADER
=
WEBUI_AUTH_TRUSTED_EMAIL_HEADER
app
.
state
.
AUTH_TRUSTED_NAME_HEADER
=
WEBUI_AUTH_TRUSTED_NAME_HEADER
app
.
state
.
config
.
SHOW_ADMIN_DETAILS
=
SHOW_ADMIN_DETAILS
app
.
state
.
config
.
SHOW_ADMIN_DETAILS
=
SHOW_ADMIN_DETAILS
...
...
backend/apps/webui/routers/auths.py
View file @
f3bd8107
...
@@ -33,7 +33,7 @@ from utils.utils import (
...
@@ -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
,
WEBUI_AUTH_TRUSTED_EMAIL_HEADER
from
config
import
WEBUI_AUTH
,
WEBUI_AUTH_TRUSTED_EMAIL_HEADER
,
WEBUI_AUTH_TRUSTED_NAME_HEADER
router
=
APIRouter
()
router
=
APIRouter
()
...
@@ -110,11 +110,14 @@ async def signin(request: Request, form_data: SigninForm):
...
@@ -110,11 +110,14 @@ async def signin(request: Request, form_data: SigninForm):
raise
HTTPException
(
400
,
detail
=
ERROR_MESSAGES
.
INVALID_TRUSTED_HEADER
)
raise
HTTPException
(
400
,
detail
=
ERROR_MESSAGES
.
INVALID_TRUSTED_HEADER
)
trusted_email
=
request
.
headers
[
WEBUI_AUTH_TRUSTED_EMAIL_HEADER
].
lower
()
trusted_email
=
request
.
headers
[
WEBUI_AUTH_TRUSTED_EMAIL_HEADER
].
lower
()
trusted_name
=
trusted_email
if
WEBUI_AUTH_TRUSTED_NAME_HEADER
:
trusted_name
=
request
.
headers
.
get
(
WEBUI_AUTH_TRUSTED_NAME_HEADER
,
trusted_email
)
if
not
Users
.
get_user_by_email
(
trusted_email
.
lower
()):
if
not
Users
.
get_user_by_email
(
trusted_email
.
lower
()):
await
signup
(
await
signup
(
request
,
request
,
SignupForm
(
SignupForm
(
email
=
trusted_email
,
password
=
str
(
uuid
.
uuid4
()),
name
=
trusted_
email
email
=
trusted_email
,
password
=
str
(
uuid
.
uuid4
()),
name
=
trusted_
name
),
),
)
)
user
=
Auths
.
authenticate_user_by_trusted_header
(
trusted_email
)
user
=
Auths
.
authenticate_user_by_trusted_header
(
trusted_email
)
...
...
backend/config.py
View file @
f3bd8107
...
@@ -294,6 +294,9 @@ WEBUI_AUTH = os.environ.get("WEBUI_AUTH", "True").lower() == "true"
...
@@ -294,6 +294,9 @@ 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
)
)
WEBUI_AUTH_TRUSTED_NAME_HEADER
=
os
.
environ
.
get
(
"WEBUI_AUTH_TRUSTED_NAME_HEADER"
,
None
)
JWT_EXPIRES_IN
=
PersistentConfig
(
JWT_EXPIRES_IN
=
PersistentConfig
(
"JWT_EXPIRES_IN"
,
"auth.jwt_expiry"
,
os
.
environ
.
get
(
"JWT_EXPIRES_IN"
,
"-1"
)
"JWT_EXPIRES_IN"
,
"auth.jwt_expiry"
,
os
.
environ
.
get
(
"JWT_EXPIRES_IN"
,
"-1"
)
)
)
...
...
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