Repository navigation
feat(api): optional API keys for the API routes - #568
Merged
Merged
Conversation
The server has no authentication, and with CORS_ORIGINS defaulting to "*" any client that can reach the port can run generation. Add API_KEYS, a list of accepted keys. When it is non-empty, the /v1, /dev, SSML, tune and debug routers require "Authorization: Bearer <key>", which is how OpenAI-compatible clients send their API key; keys are compared with secrets.compare_digest. /health, the docs and the web player's static files stay open. Empty by default, so nothing changes for existing deployments. Closes remsky#373
This was referenced Oct 28, 2026
Owner
|
Thanks David, this is a good shape. Had websocket changes incoming (#576), so I'm resolving for the broader shape with a follow-up on your PR:
Give me a shout if you have any feedback |
test(api): check /v1/test stays open with API_KEYS set
API_KEYS containing "" matched any request without credentials. Skip empty tokens and keys so such a config fails closed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
davidcoulson
added a commit
to davidcoulson/Kokoro-FastAPI
that referenced
this pull request
Oct 31, 2026
…-deploy Co-Authored-By: Claude Sonnet 5.5 <[email protected]> # Conflicts: # api/src/core/config.py # api/src/main.py # api/tests/test_kokoro_v1.py # api/tests/test_temp_manager.py
Owner
|
Big catch, thanks @davidcoulson |
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.
The server has no authentication, and with CORS_ORIGINS defaulting to
"*" any client that can reach the port can run generation. Add
API_KEYS, a list of accepted keys. When it is non-empty, the /v1, /dev,
SSML, tune and debug routers require "Authorization: Bearer ",
which is how OpenAI-compatible clients send their API key; keys are
compared with secrets.compare_digest. /health, the docs and the web
player's static files stay open. Empty by default, so nothing changes
for existing deployments.
Testing
pytest: new tests, each confirmed to fail without the fix; full suite passes.docker/gpu/Dockerfile.optimizedwith this and six sibling PRs merged.Closes #373
One of seven PRs from the same review. Each is based on master on its own; where they overlap (CHANGELOG
[Unreleased], andkokoro_v1.pyacross the OOM, voice-mix and event-loop PRs), the conflicts are mechanical.