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
e011e7b6
"...git@developer.sourcefind.cn:chenpangpang/open-webui.git" did not exist on "04ddbf43065fd8372c39665730c6a159d6013ff1"
Commit
e011e7b6
authored
Jun 21, 2024
by
Jun Siang Cheah
Browse files
fix: set auth cookie during oauth login
parent
416e8d1e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
backend/main.py
backend/main.py
+8
-1
No files found.
backend/main.py
View file @
e011e7b6
...
@@ -1870,7 +1870,7 @@ async def oauth_login(provider: str, request: Request):
...
@@ -1870,7 +1870,7 @@ async def oauth_login(provider: str, request: Request):
@
app
.
get
(
"/oauth/{provider}/callback"
)
@
app
.
get
(
"/oauth/{provider}/callback"
)
async
def
oauth_callback
(
provider
:
str
,
request
:
Request
):
async
def
oauth_callback
(
provider
:
str
,
request
:
Request
,
response
:
Response
):
if
provider
not
in
OAUTH_PROVIDERS
:
if
provider
not
in
OAUTH_PROVIDERS
:
raise
HTTPException
(
404
)
raise
HTTPException
(
404
)
client
=
oauth
.
create_client
(
provider
)
client
=
oauth
.
create_client
(
provider
)
...
@@ -1953,6 +1953,13 @@ async def oauth_callback(provider: str, request: Request):
...
@@ -1953,6 +1953,13 @@ async def oauth_callback(provider: str, request: Request):
expires_delta
=
parse_duration
(
webui_app
.
state
.
config
.
JWT_EXPIRES_IN
),
expires_delta
=
parse_duration
(
webui_app
.
state
.
config
.
JWT_EXPIRES_IN
),
)
)
# Set the cookie token
response
.
set_cookie
(
key
=
"token"
,
value
=
token
,
httponly
=
True
,
# Ensures the cookie is not accessible via JavaScript
)
# Redirect back to the frontend with the JWT token
# Redirect back to the frontend with the JWT token
redirect_url
=
f
"
{
request
.
base_url
}
auth#token=
{
jwt_token
}
"
redirect_url
=
f
"
{
request
.
base_url
}
auth#token=
{
jwt_token
}
"
return
RedirectResponse
(
url
=
redirect_url
)
return
RedirectResponse
(
url
=
redirect_url
)
...
...
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