Repository navigation
Conversation
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.
What
An opt-in shared bearer token for the
/v1/*routes, so small deployments can stopGET /v1/capabilities/:holderfrom answering anyone who reaches the port, without a reverse proxy.KEYGATE_API_TOKENSis a comma-separated list, validated insrc/config.tsthroughConfigSchema. Empty entries and tokens shorter than 32 characters are reported with the other config errors./v1/*route requiresAuthorization: Bearer <token>. A missing or wrong token gets401 {"error":"unauthorized"}withwww-authenticate: Bearer.crypto.timingSafeEqualon SHA-256 digests, so the comparison does not depend on the length of the presented value. Every configured token is checked even after a match./healthzand/readyzstay unauthenticated.authorizationheader..env.example, the README configuration section andSECURITY.mditem 5 are updated to match.Tests
test/config.test.ts: a valid list, an empty entry, and a short token.test/server.test.ts: no header, wrong token, a right token from a list, health routes open, and no tokens configured.Checks run locally:
npx vitest run: 129 passednpx tsc --noEmit: cleannpx eslint src test: cleannpx prettier --check src test: cleanRegression test: untested: a small feature has no test that fails before the change
Fixes #3