security: add API key authentication to all API endpoints#437
Open
aaniya22 wants to merge 2 commits into
Open
Conversation
utksh1
requested changes
May 31, 2026
Owner
utksh1
left a comment
There was a problem hiding this comment.
Thanks for working on API auth. This cannot merge as-is: backend-tests are failing, the frontend/API client has no credential flow so the app would start sending unauthenticated requests, and generating/logging an API key from inside the backend is not an operator-safe rollout path. Please restore green checks, add frontend/client integration and docs, keep health/public endpoints intentional, and avoid logging secrets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #266
Every API endpoint was reachable without any credential. An attacker
with access to the backend port could read vault secrets, wipe scan
history, or start arbitrary scans.
Changes:
backend/secuscan/auth.pywithrequire_api_keydependencySECUSCAN_API_KEYis not set, a random 64-charhex key is generated, saved to
data/api_key.txt, and logged once/api/v1/*must supply the key as:Authorization: Bearer <key>orX-Api-Key: <key>/api/v1/health,/docs,/redoc,/remain publicSECUSCAN_API_KEYtoconfig.pyand documented in.env.exampleNo breaking change for users who set
SECUSCAN_API_KEYin their env.Users without it get a key auto-generated and logged on first run.