Skip to content

fix(api): require auth on /api/upload-auth#2

Open
abdout wants to merge 1 commit into
mainfrom
fix/api-upload-auth-guard
Open

fix(api): require auth on /api/upload-auth#2
abdout wants to merge 1 commit into
mainfrom
fix/api-upload-auth-guard

Conversation

@abdout
Copy link
Copy Markdown
Contributor

@abdout abdout commented Apr 25, 2026

Summary

  • /api/upload-auth was an unauthenticated GET returning ImageKit upload credentials to anyone — a credential-leak vector against our ImageKit quota.
  • Adds auth() guard, returns 401 on no session, no other behavior change.
  • The single caller (src/components/ui/file-upload.tsx) already throws on non-OK responses, so the unauth path surfaces as a UI error rather than a crash.

Changes

  • src/app/api/upload-auth/route.ts — import auth from @/auth, return 401 when no session

Test plan

  • `curl -i http://localhost:3000/api/upload-auth\` → 401 when not signed in
  • Sign in, hit endpoint via `` component → token/signature returned, upload succeeds
  • Verify no regression on existing authenticated upload flow

Closes #1

🤖 Generated with Claude Code

Mints ImageKit upload credentials only for authenticated sessions.
Previously the endpoint was a public GET that returned token/expire/
signature/publicKey to anyone — letting attackers upload arbitrary
content to our ImageKit account against our quota.

Closes #1

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marketing Ready Ready Preview, Comment Apr 25, 2026 8:32am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(api): /api/upload-auth is unauthenticated — anyone can mint ImageKit upload tokens

1 participant