Commit 5ac890f0 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Remix: no raw download link, library-only

A finished remix was already auto-added to the caller's library as a
real LibrarySong (that part was never the problem) - but GET
/remix/{job_id} also handed back a public, unauthenticated
/downloads/{filename} URL. Anyone with or guessing that URL could
fetch the file with no auth check at all, regardless of who owns it.
Removed that field entirely; the result is only reachable the same
way everything else in the library is - streamed through the
authenticated /library endpoints via library_song_id.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent d6fa0f2f
Pipeline #1127 passed with stage
in 4 minutes and 19 seconds
...@@ -4,7 +4,7 @@ import shutil ...@@ -4,7 +4,7 @@ import shutil
import uuid import uuid
from typing import List, Optional from typing import List, Optional
from fastapi import APIRouter, BackgroundTasks, Depends, File, Form, HTTPException, Request, UploadFile from fastapi import APIRouter, BackgroundTasks, Depends, File, Form, HTTPException, UploadFile
from sqlalchemy.orm import Session from sqlalchemy.orm import Session
from src.core.database import LibrarySong, RemixJob, User, get_db from src.core.database import LibrarySong, RemixJob, User, get_db
...@@ -91,7 +91,6 @@ async def create_remix( ...@@ -91,7 +91,6 @@ async def create_remix(
@router.get("/{job_id}") @router.get("/{job_id}")
async def get_remix_status( async def get_remix_status(
job_id: int, job_id: int,
request: Request,
db: Session = Depends(get_db), db: Session = Depends(get_db),
current_user: User = Depends(get_current_user), current_user: User = Depends(get_current_user),
): ):
...@@ -110,7 +109,10 @@ async def get_remix_status( ...@@ -110,7 +109,10 @@ async def get_remix_status(
if job.plan_json: if job.plan_json:
response["plan"] = json.loads(job.plan_json) response["plan"] = json.loads(job.plan_json)
if job.status == "done" and job.result_filename: if job.status == "done" and job.result_filename:
response["download_url"] = f"{str(request.base_url).rstrip('/')}/downloads/{job.result_filename}" # Deliberately no raw download link here - the finished remix is already added to
# the caller's library (library_song_id) as a real LibrarySong, streamable the same
# authenticated way as anything else there. A public /downloads URL would hand out
# an unauthenticated copy of the file to anyone who has or guesses it.
response["library_song_id"] = job.result_song_id response["library_song_id"] = job.result_song_id
response["post_id"] = job.result_post_id response["post_id"] = job.result_post_id
if job.status == "error": if job.status == "error":
......
...@@ -209,6 +209,9 @@ def test_remix_status_surfaces_library_and_post_ids_when_done(client, auth_as, m ...@@ -209,6 +209,9 @@ def test_remix_status_surfaces_library_and_post_ids_when_done(client, auth_as, m
body = status_response.json() body = status_response.json()
assert body["status"] == "done" assert body["status"] == "done"
assert body["library_song_id"] == 123 assert body["library_song_id"] == 123
# No raw download link - the finished remix is only reachable as a LibrarySong via the
# normal authenticated library/stream endpoints, not a public /downloads URL.
assert "download_url" not in body
assert body["post_id"] == 456 assert body["post_id"] == 456
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment