Repository navigation
fix(billing): register the Stripe plugin only when the webhook secret is configured - #9363
Conversation
… is configured The Better Auth Stripe plugin was passed `STRIPE_WEBHOOK_SECRET || ''`. Stripe's verifier accepts signatures computed with an empty key, so the plugin's own falsy-secret check was the only thing keeping the receiver from accepting forged events. Billing now registers only when the webhook secret is set, logging an error otherwise, and the setup preflight requires it alongside STRIPE_SECRET_KEY.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryStripe billing now registers only when billing is enabled and both Stripe secrets are present.
Reviews (2) · Last reviewed commit: "fix(billing): treat a whitespace-only St..." · Reviewed by Greptile |
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
Turn on auto-fix | Re-trigger cubic
Summary
stripeWebhookSecret: env.STRIPE_WEBHOOK_SECRET || ''. Stripe's verifier accepts a signature computed with an empty key, so with billing on and the secret unset, the plugin's own falsy-secret check was the only thing keeping/api/auth/stripe/webhookfrom accepting forged events@better-auth/stripe@1.6.27(it 500s withSTRIPE_WEBHOOK_SECRET_NOT_FOUNDbefore verifying), but we shouldn't depend on thatresolveStripeBilling()now returns the client + secret only when billing is on and bothSTRIPE_SECRET_KEYandSTRIPE_WEBHOOK_SECRETare set; otherwise it logs an error and the plugin (andstripeCustomerIduser field) stay unregistered, the same state as billing on with no Stripe keyenv.tsruns withskipValidation: true)sim-setuppreflight now requiresSTRIPE_WEBHOOK_SECRETalongsideSTRIPE_SECRET_KEYwhenBILLING_ENABLEDis onType of Change
Testing
@/lib/auth/authmodule under each billing env config onorigin/stagingand on this branch, posting forged (empty-key HMAC) and correctly signed events to/api/auth/stripe/webhookand an unauthenticated/api/auth/subscription/upgrade:stripe.webhooks.constructEvent(payload, sig, '')accepts a signature forged with an empty key (Node crypto provider)packages/sim-setup/src/checks.test.ts, biome, comment hygiene; type-check and audits left to CIChecklist
test-auditauthoring gate)