Skip to content

fix(security): require API key for production score endpoint#9

Merged
aytzey merged 1 commit into
mainfrom
codex/propose-fix-for-unauthenticated-scoring-api
Apr 24, 2026
Merged

fix(security): require API key for production score endpoint#9
aytzey merged 1 commit into
mainfrom
codex/propose-fix-for-unauthenticated-scoring-api

Conversation

@aytzey

@aytzey aytzey commented Apr 24, 2026

Copy link
Copy Markdown
Owner

Motivation

  • The public Traefik routing exposed the expensive /api/score endpoint without authentication, enabling unauthenticated remote abuse of GPU/LLM resources.
  • The intent is to add a minimal, production-only gate that blocks unauthenticated requests while preserving local/dev ergonomics.
  • The deployment should fail fast if operators forget to configure the secret, preventing accidental public exposure.

Description

  • Added a production-only isAuthorized check in app/api/score/route.ts that requires SCORE_API_KEY and accepts x-api-key or Authorization: Bearer <key>, returning 503 for misconfiguration and 401 for unauthorized requests.
  • Early-return auth logic is applied before parsing/forwarding requests to scorePitch so existing scoring behavior is preserved for authorized calls.
  • Updated docker-compose.yml to require SCORE_API_KEY for the web service at startup (SCORE_API_KEY: ${SCORE_API_KEY:?SCORE_API_KEY must be set}).
  • Added SCORE_API_KEY to .env.example and extended tests/api/score.test.ts with tests covering production misconfiguration and unauthorized access.

Testing

  • Ran npm test -- --run tests/api/score.test.ts and the suite passed (8 tests).
  • Attempted pytest -q tests/infra/test_docker_compose.py but it failed in this environment because the docker CLI is not available, so compose config validation could not be executed.
  • Unit tests covering the new auth behavior succeeded and existing route tests remain passing.

Codex Task

@coderabbitai

coderabbitai Bot commented Apr 24, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@aytzey has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 58 minutes and 51 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 58 minutes and 51 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b030f258-2669-44a9-b384-8250d241650b

📥 Commits

Reviewing files that changed from the base of the PR and between db78ad5 and f2352a6.

📒 Files selected for processing (4)
  • .env.example
  • app/api/score/route.ts
  • docker-compose.yml
  • tests/api/score.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/propose-fix-for-unauthenticated-scoring-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@aytzey aytzey merged commit 016ffb6 into main Apr 24, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant