feat: add optional bearer token authentication #10
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.
Thanks for the project! I wanted to use it, but decided to run my own instance to avoid potential overuse of yours. Since I'm running my own, I wanted to put some basic authentication in place, so I made this addition to support configuring 1 or more API tokens. If the
API_TOKENSenv var is not set, the behavior is unchanged.Implement API token authentication using FastAPI's built-in security utilities. When the API_TOKENS environment variable is set, all API endpoints require a valid bearer token.
Implementation details:
Usage:
Without auth (development) uvicorn src.api:app --reload
With auth (production) API_TOKENS="token1,token2" uvicorn src.api:app
Making authenticated requests curl -H "Authorization: Bearer token1" http://localhost:8000/top_players/
🤖 Generated with Claude Code