feat: API authentication -- bearer token / API key for all REST endpoints #49
Labels
No labels
compliance
demo
deployment
docs
enhancement
parser
patterns
performance
security
ux
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Circuit-Forge/turnstone#49
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The Turnstone REST API currently has no authentication. All endpoints are open to anyone who can reach port 8534. This is acceptable on a trusted LAN but not for any deployment that faces an enterprise network or is proxied publicly.
Design:
TURNSTONE_API_KEYenv var (simple, no DB overhead)/api/*requireAuthorization: Bearer <key>orX-API-Key: <key>header/api/diagnose/stream,/api/glean/stream) must also be protectedTURNSTONE_API_KEYpassed asVITE_API_KEYbuild var or runtime config endpointWhat auth does NOT cover in this issue:
Acceptance criteria:
curl http://localhost:8534/api/sourcesreturns 401 when key is set and header is absentcurl -H "X-API-Key: mykey" http://localhost:8534/api/sourcesreturns 200Implemented in
app/rest.py.TURNSTONE_API_KEYenv var (unset = no auth, backward compatible)_check_api_key(request)FastAPI dependency usinghmac.compare_digestfor timing-safe comparisonrouterand_ctx(context endpoints) viadependencies=[Depends(...)]/turnstone/healthalways open for monitoring tools.env.example