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
99e7b328
Commit
99e7b328
authored
Jun 24, 2024
by
Jun Siang Cheah
Browse files
refac: add better logging for oauth errors
parent
981f3841
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
backend/main.py
backend/main.py
+6
-2
No files found.
backend/main.py
View file @
99e7b328
...
@@ -1883,17 +1883,19 @@ async def oauth_callback(provider: str, request: Request, response: Response):
...
@@ -1883,17 +1883,19 @@ async def oauth_callback(provider: str, request: Request, response: Response):
try
:
try
:
token
=
await
client
.
authorize_access_token
(
request
)
token
=
await
client
.
authorize_access_token
(
request
)
except
Exception
as
e
:
except
Exception
as
e
:
log
.
error
(
f
"OAuth callback error:
{
e
}
"
)
log
.
warning
(
f
"OAuth callback error:
{
e
}
"
)
raise
HTTPException
(
400
,
detail
=
ERROR_MESSAGES
.
INVALID_CRED
)
raise
HTTPException
(
400
,
detail
=
ERROR_MESSAGES
.
INVALID_CRED
)
user_data
:
UserInfo
=
token
[
"userinfo"
]
user_data
:
UserInfo
=
token
[
"userinfo"
]
sub
=
user_data
.
get
(
"sub"
)
sub
=
user_data
.
get
(
"sub"
)
if
not
sub
:
if
not
sub
:
log
.
warning
(
f
"OAuth callback failed, sub is missing:
{
user_data
}
"
)
raise
HTTPException
(
400
,
detail
=
ERROR_MESSAGES
.
INVALID_CRED
)
raise
HTTPException
(
400
,
detail
=
ERROR_MESSAGES
.
INVALID_CRED
)
provider_sub
=
f
"
{
provider
}
@
{
sub
}
"
provider_sub
=
f
"
{
provider
}
@
{
sub
}
"
email
=
user_data
.
get
(
"email"
,
""
).
lower
()
email
=
user_data
.
get
(
"email"
,
""
).
lower
()
# We currently mandate that email addresses are provided
# We currently mandate that email addresses are provided
if
not
email
:
if
not
email
:
log
.
warning
(
f
"OAuth callback failed, email is missing:
{
user_data
}
"
)
raise
HTTPException
(
400
,
detail
=
ERROR_MESSAGES
.
INVALID_CRED
)
raise
HTTPException
(
400
,
detail
=
ERROR_MESSAGES
.
INVALID_CRED
)
# Check if the user exists
# Check if the user exists
...
@@ -1958,7 +1960,9 @@ async def oauth_callback(provider: str, request: Request, response: Response):
...
@@ -1958,7 +1960,9 @@ async def oauth_callback(provider: str, request: Request, response: Response):
},
},
)
)
else
:
else
:
raise
HTTPException
(
400
,
detail
=
ERROR_MESSAGES
.
INVALID_CRED
)
raise
HTTPException
(
status
.
HTTP_403_FORBIDDEN
,
detail
=
ERROR_MESSAGES
.
ACCESS_PROHIBITED
)
jwt_token
=
create_token
(
jwt_token
=
create_token
(
data
=
{
"id"
:
user
.
id
},
data
=
{
"id"
:
user
.
id
},
...
...
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