commit a68ba0edecfcb3b7dfec7b28b59b6d16f89b5c26
parent 68314d3ba6a0e677161b98d99fc414970f3bec9f
Author: Amit Dutta <mail@amit.is-a.dev>
Date: Fri, 4 Sep 2026 07:18:13 +0530
Merge pull request #10 from notamitgamer/feat/open-uploads
Make /upload open — remove auth token requirement
Diffstat:
4 files changed, 2 insertions(+), 28 deletions(-)
diff --git a/app/auth.py b/app/auth.py
@@ -1,16 +0,0 @@
-import os
-from fastapi import Header, HTTPException
-
-# Phase 6: Security
-ADMIN_TOKEN = os.getenv("ADMIN_TOKEN")
-
-def verify_token(authorization: str = Header(None)):
- if not ADMIN_TOKEN:
- raise HTTPException(status_code=500, detail="Server missing ADMIN_TOKEN configuration")
-
- if not authorization or not authorization.startswith("Bearer "):
- raise HTTPException(status_code=401, detail="Unauthorized")
-
- token = authorization.split(" ")[1]
- if token != ADMIN_TOKEN:
- raise HTTPException(status_code=401, detail="Unauthorized")-
\ No newline at end of file
diff --git a/app/main.py b/app/main.py
@@ -4,12 +4,11 @@ import uuid
import mimetypes
import httpx
from pathlib import Path
-from fastapi import FastAPI, Request, File, UploadFile, Depends, HTTPException
+from fastapi import FastAPI, Request, File, UploadFile, HTTPException
from fastapi.responses import StreamingResponse, HTMLResponse, PlainTextResponse, RedirectResponse, FileResponse
from fastapi.templating import Jinja2Templates
from .storage import is_file, list_directory, upload_temp_file, HF_REPO_ID
-from .auth import verify_token
app = FastAPI()
@@ -134,7 +133,7 @@ async def download_file(path: str):
return StreamingResponse(stream_generator(), headers=headers)
@app.post("/api/upload")
-async def handle_upload(files: list[UploadFile] = File(...), _ = Depends(verify_token)):
+async def handle_upload(files: list[UploadFile] = File(...)):
results = []
for file in files:
temp_path = f"/tmp/{uuid.uuid4()}-{file.filename}"
diff --git a/app/templates/index.html b/app/templates/index.html
@@ -380,8 +380,6 @@
If you do not remember the link, go to the <a href="/uploads">uploads folder</a> to find your file.
</blockquote>
- <input type="hidden" id="token" value="Amitthehack2006">
-
<div id="dropzone">
<div>drag & drop files here</div>
<div style="font-size: 0.8rem; margin-top: 0.5rem;">or click to select</div>
@@ -394,7 +392,6 @@
<script>
const dropzone = document.getElementById('dropzone');
const fileInput = document.getElementById('file-input');
- const tokenInput = document.getElementById('token');
const results = document.getElementById('results');
const errorBox = document.getElementById('error-box');
@@ -416,7 +413,6 @@
function handleFiles(fileList) {
errorBox.style.display = 'none';
- const token = tokenInput.value;
const files = Array.from(fileList);
const rows = {};
@@ -433,8 +429,6 @@
const xhr = new XMLHttpRequest();
xhr.open('POST', '/api/upload', true);
-
- xhr.setRequestHeader('Authorization', 'Bearer ' + token);
xhr.upload.onprogress = (e) => {
if (!e.lengthComputable) return;
diff --git a/render.yaml b/render.yaml
@@ -8,8 +8,6 @@ services:
value: notamitgamer/cdn
- key: HF_TOKEN
sync: false
- - key: ADMIN_TOKEN
- sync: false
- key: RAW_DOMAIN
value: raw.cdn.amit.is-a.dev
- key: RAW_BASE_URL