Repository navigation
Require a secret for POST /api/licenses; fail closed without a webhook secret - #2
Merged
Merged
Conversation
…a webhook secret POST /api/licenses created licenses with the admin API key and had no authentication, so anyone who found a deployed starter could mint licenses. It now requires Authorization: Bearer $LICENSE_API_SECRET (constant-time compare), refuses requests until the secret is set, validates the email and maxActivations (1-100), and no longer echoes admin-client errors. The webhook route now refuses requests when KEYMINT_WEBHOOK_SECRET is unset (an empty HMAC key is forgeable) and treats a wrong-length signature as invalid instead of throwing.
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.
POST /api/licenses was unauthenticated. It creates licenses with your Keymint admin API key, so anyone who found a deployed copy of this starter could create licenses in your account.
Changes
POST /api/licensesnow requiresAuthorization: Bearer $LICENSE_API_SECRET, compared in constant time. It refuses all requests (503) untilLICENSE_API_SECRETis set.customerEmail, and an integermaxActivationsfrom 1 to 100. Errors from the admin client are logged on the server and no longer returned to the caller.POST /api/webhooks/keymintrefuses all requests (503) untilKEYMINT_WEBHOOK_SECRETis set, because an empty HMAC key would let anyone forge a signature. A signature of the wrong length is now rejected instead of crashing (timingSafeEqualthrows on different lengths)..env.example, the README and the dashboard page documentLICENSE_API_SECRET. The README also recommends creating licenses from your payment provider's webhook rather than exposing this route.The signature format matches what Keymint sends (
Keymint-Signature: t=<ts>,v1=<HMAC-SHA256(secret, ts + "." + body)>).tsc --noEmitis clean.