Skip to content

Commit

Permalink
fix: oauth redirection with root path
Browse files Browse the repository at this point in the history
  • Loading branch information
willydouhard committed Jun 21, 2024
1 parent 86ded88 commit 613a12c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

Nothing unreleased.

## [1.1.304] - 2024-06-21

### Fixed

- OAuth final redirection should account for root path if provided

## [1.1.303] - 2024-06-20

### Fixed
Expand Down
12 changes: 8 additions & 4 deletions backend/chainlit/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,6 @@ def get_user_facing_url(url: URL):
Return the user facing URL for a given URL.
Handles deployment with proxies (like cloud run).
"""

ROOT_PATH = os.environ.get("CHAINLIT_ROOT_PATH", "")
chainlit_url = os.environ.get("CHAINLIT_URL")

# No config, we keep the URL as is
Expand Down Expand Up @@ -524,9 +522,12 @@ async def oauth_callback(
"token_type": "bearer",
}
)

root_path = os.environ.get("CHAINLIT_ROOT_PATH", "")

response = RedirectResponse(
# FIXME: redirect to the right frontend base url to improve the dev environment
url=f"/login/callback?{params}",
url=f"{root_path}/login/callback?{params}",
)
response.delete_cookie("oauth_state")
return response
Expand Down Expand Up @@ -601,9 +602,12 @@ async def oauth_azure_hf_callback(
"token_type": "bearer",
}
)

root_path = os.environ.get("CHAINLIT_ROOT_PATH", "")

response = RedirectResponse(
# FIXME: redirect to the right frontend base url to improve the dev environment
url=f"/login/callback?{params}",
url=f"{root_path}/login/callback?{params}",
status_code=302,
)
response.delete_cookie("oauth_state")
Expand Down
2 changes: 1 addition & 1 deletion backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "chainlit"
version = "1.1.303"
version = "1.1.304"
keywords = [
'LLM',
'Agents',
Expand Down

0 comments on commit 613a12c

Please sign in to comment.