Skip to content

Commit

Permalink
Update server.py (#1474)
Browse files Browse the repository at this point in the history
Solving the underlying issue properly requires moving to HTTP only cookies, which is out of scope for now (we want to properly clean up auth). We're gonna ship this ASAP.

This reopens #1101 and #1438 .
  • Loading branch information
hayescode authored Oct 25, 2024
1 parent 2556985 commit 49dd1a5
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions backend/chainlit/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ async def upload_file(
async def get_file(
file_id: str,
session_id: str,
current_user: Annotated[Union[User, PersistedUser], Depends(get_current_user)],
# current_user: Annotated[Union[User, PersistedUser], Depends(get_current_user)], #TODO: Causes 401 error. See https://github.com/Chainlit/chainlit/issues/1472
):
"""Get a file from the session files directory."""

Expand All @@ -895,12 +895,13 @@ async def get_file(
detail="Unauthorized",
)

if current_user:
if not session.user or session.user.identifier != current_user.identifier:
raise HTTPException(
status_code=401,
detail="You are not authorized to download files from this session",
)
#TODO: Causes 401 error. See https://github.com/Chainlit/chainlit/issues/1472
# if current_user:
# if not session.user or session.user.identifier != current_user.identifier:
# raise HTTPException(
# status_code=401,
# detail="You are not authorized to download files from this session",
# )

if file_id in session.files:
file = session.files[file_id]
Expand Down

0 comments on commit 49dd1a5

Please sign in to comment.