feat: Require ownership attestation before processing a video
- MediaInput shows a checkbox the user must tick before Generate enables - Frontend sends acknowledged=true alongside URL/file payload - /api/process rejects with 400 if attestation is missing, and records IP/UA/timestamp/source on the job for legal record-keeping Defensive posture for the public deployment: shifts responsibility to the user via an explicit affirmative act, even without login. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3f4c814e22
commit
12c1b8e1d5
3 changed files with 53 additions and 14 deletions
28
app.py
28
app.py
|
|
@ -317,24 +317,45 @@ async def get_config():
|
|||
async def process_endpoint(
|
||||
request: Request,
|
||||
file: Optional[UploadFile] = File(None),
|
||||
url: Optional[str] = Form(None)
|
||||
url: Optional[str] = Form(None),
|
||||
acknowledged: Optional[str] = Form(None)
|
||||
):
|
||||
api_key = request.headers.get("X-Gemini-Key")
|
||||
if not api_key:
|
||||
raise HTTPException(status_code=400, detail="Missing X-Gemini-Key header")
|
||||
|
||||
ack_flag = str(acknowledged).lower() in ("1", "true", "yes")
|
||||
|
||||
# Handle JSON body manually for URL payload
|
||||
content_type = request.headers.get("content-type", "")
|
||||
if "application/json" in content_type:
|
||||
body = await request.json()
|
||||
url = body.get("url")
|
||||
ack_flag = bool(body.get("acknowledged"))
|
||||
|
||||
if not url and not file:
|
||||
raise HTTPException(status_code=400, detail="Must provide URL or File")
|
||||
|
||||
if not ack_flag:
|
||||
raise HTTPException(status_code=400, detail="You must confirm you own the content or have rights to process it.")
|
||||
|
||||
if url and DISABLE_YOUTUBE_URL:
|
||||
raise HTTPException(status_code=403, detail="YouTube URL ingest is disabled on this deployment. Please upload a file you own.")
|
||||
|
||||
# Capture attestation context for legal record (IP + timestamp + UA)
|
||||
client_ip = request.client.host if request.client else "unknown"
|
||||
fwd = request.headers.get("x-forwarded-for")
|
||||
if fwd:
|
||||
client_ip = fwd.split(",")[0].strip()
|
||||
user_agent = request.headers.get("user-agent", "")
|
||||
attestation = {
|
||||
"acknowledged": True,
|
||||
"ip": client_ip,
|
||||
"user_agent": user_agent,
|
||||
"timestamp": time.time(),
|
||||
"source": "url" if url else "file",
|
||||
}
|
||||
|
||||
job_id = str(uuid.uuid4())
|
||||
job_output_dir = os.path.join(OUTPUT_DIR, job_id)
|
||||
os.makedirs(job_output_dir, exist_ok=True)
|
||||
|
|
@ -367,13 +388,16 @@ async def process_endpoint(
|
|||
|
||||
cmd.extend(["-o", job_output_dir])
|
||||
|
||||
print(f"[attestation] job={job_id} ip={attestation['ip']} source={attestation['source']} ack=true")
|
||||
|
||||
# Enqueue Job
|
||||
jobs[job_id] = {
|
||||
'status': 'queued',
|
||||
'logs': [f"Job {job_id} queued."],
|
||||
'cmd': cmd,
|
||||
'env': env,
|
||||
'output_dir': job_output_dir
|
||||
'output_dir': job_output_dir,
|
||||
'attestation': attestation
|
||||
}
|
||||
|
||||
await job_queue.put(job_id)
|
||||
|
|
|
|||
|
|
@ -336,10 +336,11 @@ function App() {
|
|||
|
||||
if (data.type === 'url') {
|
||||
headers['Content-Type'] = 'application/json';
|
||||
body = JSON.stringify({ url: data.payload });
|
||||
body = JSON.stringify({ url: data.payload, acknowledged: !!data.acknowledged });
|
||||
} else {
|
||||
const formData = new FormData();
|
||||
formData.append('file', data.payload);
|
||||
formData.append('acknowledged', data.acknowledged ? 'true' : 'false');
|
||||
body = formData;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ export default function MediaInput({ onProcess, isProcessing }) {
|
|||
const [mode, setMode] = useState('url'); // 'url' | 'file'
|
||||
const [url, setUrl] = useState('');
|
||||
const [file, setFile] = useState(null);
|
||||
const [acknowledged, setAcknowledged] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
fetch(getApiUrl('/api/config'))
|
||||
|
|
@ -22,10 +23,11 @@ export default function MediaInput({ onProcess, isProcessing }) {
|
|||
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
if (!acknowledged) return;
|
||||
if (mode === 'url' && url) {
|
||||
onProcess({ type: 'url', payload: url });
|
||||
onProcess({ type: 'url', payload: url, acknowledged: true });
|
||||
} else if (mode === 'file' && file) {
|
||||
onProcess({ type: 'file', payload: file });
|
||||
onProcess({ type: 'file', payload: file, acknowledged: true });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -111,10 +113,22 @@ export default function MediaInput({ onProcess, isProcessing }) {
|
|||
</div>
|
||||
)}
|
||||
|
||||
<label className="flex items-start gap-2 mt-5 text-xs text-zinc-400 cursor-pointer select-none">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={acknowledged}
|
||||
onChange={(e) => setAcknowledged(e.target.checked)}
|
||||
className="mt-0.5 accent-primary cursor-pointer"
|
||||
/>
|
||||
<span>
|
||||
I confirm I own this content or have the rights to process it. I am responsible for any content I submit.
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isProcessing || (mode === 'url' && !url) || (mode === 'file' && !file)}
|
||||
className="w-full btn-primary mt-6 flex items-center justify-center gap-2"
|
||||
disabled={isProcessing || !acknowledged || (mode === 'url' && !url) || (mode === 'file' && !file)}
|
||||
className="w-full btn-primary mt-4 flex items-center justify-center gap-2"
|
||||
>
|
||||
{isProcessing ? (
|
||||
<>
|
||||
|
|
|
|||
Loading…
Reference in a new issue