[PR #6698] [MERGED] test: add tests for API key quota persistence and magic link origin validation #32433

Closed
opened 2026-04-17 23:14:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6698
Author: @Bekacru
Created: 12/11/2025
Status: Merged
Merged: 12/11/2025
Merged by: @Bekacru

Base: canaryHead: fix/api-key-limit


📝 Commits (1)

  • e299dec test: add tests for API key quota persistence and magic link origin validation

📊 Changes

3 files changed (+115 additions, -2 deletions)

View changed files

📝 packages/better-auth/src/plugins/api-key/api-key.test.ts (+39 -0)
📝 packages/better-auth/src/plugins/api-key/routes/verify-api-key.ts (+30 -2)
📝 packages/better-auth/src/plugins/magic-link/magic-link.test.ts (+46 -0)

📄 Description

Summary by cubic

Ensures API key quota changes persist to the database when using secondary storage with fallback, and blocks untrusted magic link callback URLs. Adds tests covering quota persistence and origin validation.

  • Bug Fixes
    • API keys: In secondary-storage + fallbackToDatabase mode, quota updates persist to the DB and storage; revoked keys are deleted from both, preventing stale allowances after cache eviction.
    • Magic link: verify rejects callbackURL not in trustedOrigins with 403 and "Invalid callbackURL".

Written for commit e299decf23. Summary will update automatically on new commits.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/6698 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 12/11/2025 **Status:** ✅ Merged **Merged:** 12/11/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/api-key-limit` --- ### 📝 Commits (1) - [`e299dec`](https://github.com/better-auth/better-auth/commit/e299decf2373fbccd2baa29f095294b0885fa8ec) test: add tests for API key quota persistence and magic link origin validation ### 📊 Changes **3 files changed** (+115 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/plugins/api-key/api-key.test.ts` (+39 -0) 📝 `packages/better-auth/src/plugins/api-key/routes/verify-api-key.ts` (+30 -2) 📝 `packages/better-auth/src/plugins/magic-link/magic-link.test.ts` (+46 -0) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Ensures API key quota changes persist to the database when using secondary storage with fallback, and blocks untrusted magic link callback URLs. Adds tests covering quota persistence and origin validation. - **Bug Fixes** - API keys: In secondary-storage + fallbackToDatabase mode, quota updates persist to the DB and storage; revoked keys are deleted from both, preventing stale allowances after cache eviction. - Magic link: verify rejects callbackURL not in trustedOrigins with 403 and "Invalid callbackURL". <sup>Written for commit e299decf2373fbccd2baa29f095294b0885fa8ec. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-17 23:14:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#32433