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
3715994c
Unverified
Commit
3715994c
authored
Aug 07, 2024
by
Timothy Jaeryang Baek
Committed by
GitHub
Aug 07, 2024
Browse files
Merge pull request #4439 from cdgco/dev
feat: Add OAuth Email Claim Variable
parents
dbe463a5
d72d5d0e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
1 deletion
+10
-1
backend/apps/webui/main.py
backend/apps/webui/main.py
+2
-0
backend/config.py
backend/config.py
+6
-0
backend/main.py
backend/main.py
+2
-1
No files found.
backend/apps/webui/main.py
View file @
3715994c
...
...
@@ -46,6 +46,7 @@ from config import (
AppConfig
,
OAUTH_USERNAME_CLAIM
,
OAUTH_PICTURE_CLAIM
,
OAUTH_EMAIL_CLAIM
,
)
from
apps.socket.main
import
get_event_call
,
get_event_emitter
...
...
@@ -84,6 +85,7 @@ app.state.config.ENABLE_COMMUNITY_SHARING = ENABLE_COMMUNITY_SHARING
app
.
state
.
config
.
OAUTH_USERNAME_CLAIM
=
OAUTH_USERNAME_CLAIM
app
.
state
.
config
.
OAUTH_PICTURE_CLAIM
=
OAUTH_PICTURE_CLAIM
app
.
state
.
config
.
OAUTH_EMAIL_CLAIM
=
OAUTH_EMAIL_CLAIM
app
.
state
.
MODELS
=
{}
app
.
state
.
TOOLS
=
{}
...
...
backend/config.py
View file @
3715994c
...
...
@@ -433,6 +433,12 @@ OAUTH_PICTURE_CLAIM = PersistentConfig(
os
.
environ
.
get
(
"OAUTH_PICTURE_CLAIM"
,
"picture"
),
)
OAUTH_EMAIL_CLAIM
=
PersistentConfig
(
"OAUTH_EMAIL_CLAIM"
,
"oauth.oidc.email_claim"
,
os
.
environ
.
get
(
"OAUTH_EMAIL_CLAIM"
,
"email"
),
)
def
load_oauth_providers
():
OAUTH_PROVIDERS
.
clear
()
...
...
backend/main.py
View file @
3715994c
...
...
@@ -2158,7 +2158,8 @@ async def oauth_callback(provider: str, request: Request, response: Response):
log
.
warning
(
f
"OAuth callback failed, sub is missing:
{
user_data
}
"
)
raise
HTTPException
(
400
,
detail
=
ERROR_MESSAGES
.
INVALID_CRED
)
provider_sub
=
f
"
{
provider
}
@
{
sub
}
"
email
=
user_data
.
get
(
"email"
,
""
).
lower
()
email_claim
=
webui_app
.
state
.
config
.
OAUTH_EMAIL_CLAIM
email
=
user_data
.
get
(
email_claim
,
""
).
lower
()
# We currently mandate that email addresses are provided
if
not
email
:
log
.
warning
(
f
"OAuth callback failed, email is missing:
{
user_data
}
"
)
...
...
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