fix: support ?token= query param for auth (downloads from browser)
Some checks failed
Deploy Tracker / deploy (push) Failing after 4s
Some checks failed
Deploy Tracker / deploy (push) Failing after 4s
This commit is contained in:
parent
d2402dc213
commit
8b993abc37
@ -62,6 +62,7 @@ async def upload_file(
|
|||||||
@router.get("/attachments/{attachment_id}/download")
|
@router.get("/attachments/{attachment_id}/download")
|
||||||
async def download_attachment(
|
async def download_attachment(
|
||||||
attachment_id: str,
|
attachment_id: str,
|
||||||
|
token: str | None = None,
|
||||||
db: AsyncSession = Depends(get_db),
|
db: AsyncSession = Depends(get_db),
|
||||||
):
|
):
|
||||||
"""Download an attachment by ID."""
|
"""Download an attachment by ID."""
|
||||||
|
|||||||
@ -196,6 +196,7 @@ async def get_project_file(
|
|||||||
async def download_project_file(
|
async def download_project_file(
|
||||||
slug: str,
|
slug: str,
|
||||||
file_id: str,
|
file_id: str,
|
||||||
|
token: Optional[str] = Query(None),
|
||||||
db: AsyncSession = Depends(get_db),
|
db: AsyncSession = Depends(get_db),
|
||||||
):
|
):
|
||||||
"""Download project file."""
|
"""Download project file."""
|
||||||
|
|||||||
@ -104,8 +104,12 @@ async def auth_middleware(request: Request, call_next):
|
|||||||
pass
|
pass
|
||||||
elif path.startswith("/api/"):
|
elif path.startswith("/api/"):
|
||||||
auth_header = request.headers.get("authorization", "")
|
auth_header = request.headers.get("authorization", "")
|
||||||
|
token = None
|
||||||
if auth_header.startswith("Bearer "):
|
if auth_header.startswith("Bearer "):
|
||||||
token = auth_header[7:]
|
token = auth_header[7:]
|
||||||
|
elif request.query_params.get("token"):
|
||||||
|
token = request.query_params["token"]
|
||||||
|
if token:
|
||||||
# Check agent token
|
# Check agent token
|
||||||
async with async_session() as db:
|
async with async_session() as db:
|
||||||
result = await db.execute(select(Member).where(Member.token == token))
|
result = await db.execute(select(Member).where(Member.token == token))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user