[PR #7885] [CLOSED] fix: safely coerce date values from DB in OAuth provider plugin #7611

Closed
opened 2026-03-13 13:43:03 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7885
Author: @themavik
Created: 2/10/2026
Status: Closed

Base: canaryHead: fix/oauth-date-validation-7819


📝 Commits (10+)

  • a4a388d docs: improve sidebar content filtering and simplify CodeBlockTabs ren… (#7109)
  • d62d115 docs: update import path for auth in tanstack integration (#7118)
  • e19ee4d docs: add bearer plugin requirement note to device auth docs (#6351)
  • c69f597 docs: update Clerk migration guide to include bcrypt configuration (#7134)
  • c31c92f chore: bump fumadocs (#7106)
  • 7537375 docs(drizzle): cleanup code highlights
  • 9a19c88 docs: update Firestore adapter to use unscoped package name (#7187)
  • fe358c5 docs: fix SVG attributes and fumadocs type imports (#7192)
  • 3be413a docs(session): document sessions for secondary storage (#7168)
  • 6a8cf49 docs: document disableOriginCheck in options.mdx (#7199)

📊 Changes

8 files changed (+193 additions, -14 deletions)

View changed files

📝 docs/content/docs/plugins/dodopayments.mdx (+108 -2)
📝 docs/content/docs/plugins/sso.mdx (+7 -0)
📝 packages/better-auth/src/client/client.test.ts (+48 -0)
📝 packages/better-auth/src/plugins/anonymous/anon.test.ts (+1 -0)
📝 packages/better-auth/src/plugins/email-otp/index.ts (+21 -0)
📝 packages/oauth-provider/src/introspect.ts (+4 -4)
📝 packages/oauth-provider/src/register.ts (+2 -2)
📝 packages/passkey/src/routes.ts (+2 -6)

📄 Description

Summary

Fixes #7819

Root cause: The OAuth provider plugin calls .getTime() directly on date values read from the database, assuming they are always Date objects. However, database adapters (e.g., Drizzle with text() or integer() column types) may return dates as strings or numbers.

Changes

  • packages/oauth-provider/src/introspect.ts: Wrapped expiresAt and createdAt with new Date() before calling .getTime() (4 call sites)
  • packages/oauth-provider/src/register.ts: Same wrapping (2 call sites)

new Date() safely handles:

  • Date objects (returns the same date)
  • ISO strings ("2024-01-01T00:00:00Z")
  • Unix timestamps in ms (1704067200000)

Risk Assessment

Low - new Date(dateObj) is a no-op when input is already a Date.


Summary by cubic

Safely coerce DB date fields in the OAuth provider by using new Date before getTime to prevent TypeErrors with string or number values. Fixes #7819.

  • Bug Fixes

    • OAuth introspect/register: wrap expiresAt/createdAt with new Date when computing exp/iat; Passkey: delete verification by value (data.id) to ensure cleanup.
  • New Features

    • Email OTP: add rate limits for request-password-reset, reset-password, and forget-password endpoints; Docs: update DodoPayments with checkoutSession and metered usage, and SSO with a SAML warning and trustEmailVerified option.

Written for commit 98752d94d9. Summary will update 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/7885 **Author:** [@themavik](https://github.com/themavik) **Created:** 2/10/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/oauth-date-validation-7819` --- ### 📝 Commits (10+) - [`a4a388d`](https://github.com/better-auth/better-auth/commit/a4a388d6f5c39cef2507f9e59e8a18bb8f3b549e) docs: improve sidebar content filtering and simplify CodeBlockTabs ren… (#7109) - [`d62d115`](https://github.com/better-auth/better-auth/commit/d62d115469711a51dfa070f5c0f946c8a3c47c13) docs: update import path for auth in tanstack integration (#7118) - [`e19ee4d`](https://github.com/better-auth/better-auth/commit/e19ee4db43d9740e86c42bffece0f0ae87e51692) docs: add bearer plugin requirement note to device auth docs (#6351) - [`c69f597`](https://github.com/better-auth/better-auth/commit/c69f597ee5dd04bec9d7df3f1f138dadb1a736c6) docs: update Clerk migration guide to include bcrypt configuration (#7134) - [`c31c92f`](https://github.com/better-auth/better-auth/commit/c31c92f3d24f3ccfb6776d4634e0681c6dee2db5) chore: bump fumadocs (#7106) - [`7537375`](https://github.com/better-auth/better-auth/commit/7537375f903fa0d371fdd921ba275b622616a45c) docs(drizzle): cleanup code highlights - [`9a19c88`](https://github.com/better-auth/better-auth/commit/9a19c88bdd44762b4d22e742f0e4bde0f72f602a) docs: update Firestore adapter to use unscoped package name (#7187) - [`fe358c5`](https://github.com/better-auth/better-auth/commit/fe358c5bf25806fe66f47e715711a4a8045d43c9) docs: fix SVG attributes and fumadocs type imports (#7192) - [`3be413a`](https://github.com/better-auth/better-auth/commit/3be413a2899b395a9d096cd2fdc25b4aa67ce23a) docs(session): document sessions for secondary storage (#7168) - [`6a8cf49`](https://github.com/better-auth/better-auth/commit/6a8cf492eb15304a9d37facb54c22eb02630e29c) docs: document `disableOriginCheck` in options.mdx (#7199) ### 📊 Changes **8 files changed** (+193 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/dodopayments.mdx` (+108 -2) 📝 `docs/content/docs/plugins/sso.mdx` (+7 -0) 📝 `packages/better-auth/src/client/client.test.ts` (+48 -0) 📝 `packages/better-auth/src/plugins/anonymous/anon.test.ts` (+1 -0) 📝 `packages/better-auth/src/plugins/email-otp/index.ts` (+21 -0) 📝 `packages/oauth-provider/src/introspect.ts` (+4 -4) 📝 `packages/oauth-provider/src/register.ts` (+2 -2) 📝 `packages/passkey/src/routes.ts` (+2 -6) </details> ### 📄 Description ## Summary Fixes #7819 **Root cause:** The OAuth provider plugin calls `.getTime()` directly on date values read from the database, assuming they are always `Date` objects. However, database adapters (e.g., Drizzle with `text()` or `integer()` column types) may return dates as strings or numbers. ## Changes - `packages/oauth-provider/src/introspect.ts`: Wrapped `expiresAt` and `createdAt` with `new Date()` before calling `.getTime()` (4 call sites) - `packages/oauth-provider/src/register.ts`: Same wrapping (2 call sites) `new Date()` safely handles: - `Date` objects (returns the same date) - ISO strings (`"2024-01-01T00:00:00Z"`) - Unix timestamps in ms (`1704067200000`) ## Risk Assessment **Low** - `new Date(dateObj)` is a no-op when input is already a Date. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Safely coerce DB date fields in the OAuth provider by using new Date before getTime to prevent TypeErrors with string or number values. Fixes #7819. - **Bug Fixes** - OAuth introspect/register: wrap expiresAt/createdAt with new Date when computing exp/iat; Passkey: delete verification by value (data.id) to ensure cleanup. - **New Features** - Email OTP: add rate limits for request-password-reset, reset-password, and forget-password endpoints; Docs: update DodoPayments with checkoutSession and metered usage, and SSO with a SAML warning and trustEmailVerified option. <sup>Written for commit 98752d94d9c12c1512610d37e3bf24985321980a. Summary will update 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-03-13 13:43:03 -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#7611