[PR #4847] [CLOSED] feat: added device binding Fixes PR: #4274 #22512

Closed
opened 2026-04-15 21:05:57 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4847
Author: @walosha
Created: 9/23/2025
Status: Closed

Base: canaryHead: feat/device-binding


📝 Commits (10+)

  • a036cf5 feat: added device binding
  • 5a6e71e import to index
  • 27b8f61 fix errors
  • 736a3f1 undo demo files
  • 69e27fa added docs for device binding
  • cad8387 Merge branch 'canary' into feat/device-binding
  • cc112ca Merge branch 'canary' into feat/device-binding
  • 2423cca Merge branch 'canary' into feat/device-binding
  • ceaea44 Merge branch 'better-auth:canary' into feat/device-binding
  • 719f0d1 Merge branch 'canary' into feat/device-binding

📊 Changes

14 files changed (+2085 additions, -20 deletions)

View changed files

📝 docs/components/sidebar-content.tsx (+11 -0)
docs/content/docs/plugins/device-binding.mdx (+676 -0)
📝 packages/better-auth/package.json (+8 -8)
packages/better-auth/src/plugins/device-binding/client.ts (+236 -0)
packages/better-auth/src/plugins/device-binding/index.ts (+917 -0)
packages/better-auth/src/plugins/device-binding/schema.ts (+146 -0)
packages/better-auth/src/plugins/device-binding/types.ts (+78 -0)
📝 packages/better-auth/src/plugins/index.ts (+1 -0)
📝 packages/cli/package.json (+2 -2)
📝 packages/core/package.json (+2 -2)
📝 packages/expo/package.json (+2 -2)
📝 packages/sso/package.json (+2 -2)
📝 packages/stripe/package.json (+2 -2)
📝 packages/telemetry/package.json (+2 -2)

📄 Description

Summary by cubic

Add device binding to verify and trust user devices, block sign-ins from unknown devices, and manage trusted devices. Includes new server endpoints, a client plugin with helpers, cookie-based trust, and schema updates.

  • New Features

    • Server endpoints: /device-binding/register (OTP flow), /device-binding/trust, /device-binding/list, /device-binding/remove, /device-binding/status.
    • Strict mode: block login on untrusted devices; first device can auto-trust; limits and expiry for trusted devices.
    • Options: trustDuration, maxTrustedDevices, autoRegisterDevice, custom fingerprint, sendOTP, verifyTOTP/OTP.
    • Cookie-based trust (better_auth_device_binding) tied to deviceId and fingerprint; auto-renewed on login.
    • Fingerprinting combines headers and provided deviceInfo; rate limits added for all device-binding routes.
    • Client plugin and helpers for register, request/verify OTP, trust, list, remove, and status checks.
  • Migration

    • Apply schema changes: add user fields (deviceBindingEnabled, hasRegisteredDevice) and create deviceBinding and deviceVerificationOTP tables.
    • Configure sendOTP and 2FA verification functions in plugin options.
    • Initialize deviceBindingClient and handle onDeviceVerificationRequired/OTP flows in the app; ensure first-device registration if strict mode is enabled.

🔄 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/4847 **Author:** [@walosha](https://github.com/walosha) **Created:** 9/23/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `feat/device-binding` --- ### 📝 Commits (10+) - [`a036cf5`](https://github.com/better-auth/better-auth/commit/a036cf5bd2cf4720f35a529305d21cb9528d3607) feat: added device binding - [`5a6e71e`](https://github.com/better-auth/better-auth/commit/5a6e71e43efe988b59b73df4a8a62b837187b8bd) import to index - [`27b8f61`](https://github.com/better-auth/better-auth/commit/27b8f61f8a31af037edf8f3edd1d03d8959c89a5) fix errors - [`736a3f1`](https://github.com/better-auth/better-auth/commit/736a3f1abd2c561e6c8151ae867a3ed77e3638d9) undo demo files - [`69e27fa`](https://github.com/better-auth/better-auth/commit/69e27fa6d81628f2a0b603cd04d2d5d79de388c3) added docs for device binding - [`cad8387`](https://github.com/better-auth/better-auth/commit/cad8387166cceca93f4c4fb965d60298f2f26a56) Merge branch 'canary' into feat/device-binding - [`cc112ca`](https://github.com/better-auth/better-auth/commit/cc112ca5fe9081bda60754f08367cbdd81442a54) Merge branch 'canary' into feat/device-binding - [`2423cca`](https://github.com/better-auth/better-auth/commit/2423cca931118d623545f5faee3eb86467305c76) Merge branch 'canary' into feat/device-binding - [`ceaea44`](https://github.com/better-auth/better-auth/commit/ceaea44c5ee29ba0f3fd01ab7555d2721abd1749) Merge branch 'better-auth:canary' into feat/device-binding - [`719f0d1`](https://github.com/better-auth/better-auth/commit/719f0d143a4c81abbda7076c3f0ab165ab5c1613) Merge branch 'canary' into feat/device-binding ### 📊 Changes **14 files changed** (+2085 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `docs/components/sidebar-content.tsx` (+11 -0) ➕ `docs/content/docs/plugins/device-binding.mdx` (+676 -0) 📝 `packages/better-auth/package.json` (+8 -8) ➕ `packages/better-auth/src/plugins/device-binding/client.ts` (+236 -0) ➕ `packages/better-auth/src/plugins/device-binding/index.ts` (+917 -0) ➕ `packages/better-auth/src/plugins/device-binding/schema.ts` (+146 -0) ➕ `packages/better-auth/src/plugins/device-binding/types.ts` (+78 -0) 📝 `packages/better-auth/src/plugins/index.ts` (+1 -0) 📝 `packages/cli/package.json` (+2 -2) 📝 `packages/core/package.json` (+2 -2) 📝 `packages/expo/package.json` (+2 -2) 📝 `packages/sso/package.json` (+2 -2) 📝 `packages/stripe/package.json` (+2 -2) 📝 `packages/telemetry/package.json` (+2 -2) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Add device binding to verify and trust user devices, block sign-ins from unknown devices, and manage trusted devices. Includes new server endpoints, a client plugin with helpers, cookie-based trust, and schema updates. - **New Features** - Server endpoints: /device-binding/register (OTP flow), /device-binding/trust, /device-binding/list, /device-binding/remove, /device-binding/status. - Strict mode: block login on untrusted devices; first device can auto-trust; limits and expiry for trusted devices. - Options: trustDuration, maxTrustedDevices, autoRegisterDevice, custom fingerprint, sendOTP, verifyTOTP/OTP. - Cookie-based trust (better_auth_device_binding) tied to deviceId and fingerprint; auto-renewed on login. - Fingerprinting combines headers and provided deviceInfo; rate limits added for all device-binding routes. - Client plugin and helpers for register, request/verify OTP, trust, list, remove, and status checks. - **Migration** - Apply schema changes: add user fields (deviceBindingEnabled, hasRegisteredDevice) and create deviceBinding and deviceVerificationOTP tables. - Configure sendOTP and 2FA verification functions in plugin options. - Initialize deviceBindingClient and handle onDeviceVerificationRequired/OTP flows in the app; ensure first-device registration if strict mode is enabled. <!-- 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-15 21:05:57 -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#22512