[PR #4571] [CLOSED] Fix/last login method cross subdomain cookies #13701

Closed
opened 2026-04-13 09:05:24 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4571
Author: @lumpinif
Created: 9/10/2025
Status: Closed

Base: canaryHead: fix/last-login-method-cross-subdomain-cookies


📝 Commits (10+)

  • dbaae0a docs: hero section alignment with feature section on big screens (#4018)
  • ef481d8 chore: fix broken testomnial link
  • 9c46196 fix(sso): [⚠︎Security] - membership check should be required before allowing users to create sso for an organization
  • 5fdf5cd chore: update sso docs
  • efa60af chore: fix import typo
  • 3fd8581 docs: hero section alignment with feature section on big screens (#4018)
  • 64216f1 chore: fix broken testomnial link
  • 28e331a fix(sso): [⚠︎Security] - membership check should be required before allowing users to create sso for an organization
  • efa0c0b chore: update sso docs
  • 95f9e9a chore: fix import typo

📊 Changes

43 files changed (+1753 additions, -177 deletions)

View changed files

.github/workflows/main-protect.yml (+18 -0)
📝 docs/app/global.css (+1 -1)
📝 docs/components/api-method.tsx (+3 -1)
📝 docs/components/endpoint.tsx (+0 -20)
📝 docs/components/generate-secret.tsx (+1 -1)
docs/components/mobile-search-icon.tsx (+33 -0)
📝 docs/components/nav-bar.tsx (+2 -0)
📝 docs/components/nav-mobile.tsx (+31 -18)
📝 docs/components/search-dialog.tsx (+2 -2)
📝 docs/components/sidebar-content.tsx (+34 -17)
📝 docs/components/ui/code-block.tsx (+1 -1)
docs/components/ui/dynamic-code-block.tsx (+133 -0)
docs/content/blogs/0-supabase-auth-to-planetscale-migration.mdx (+370 -0)
📝 docs/content/docs/authentication/cognito.mdx (+5 -5)
📝 docs/content/docs/authentication/google.mdx (+1 -1)
📝 docs/content/docs/concepts/client.mdx (+2 -2)
📝 docs/content/docs/concepts/users-accounts.mdx (+2 -2)
docs/content/docs/guides/auth0-migration-guide.mdx (+654 -0)
📝 docs/content/docs/installation.mdx (+1 -1)
📝 docs/content/docs/integrations/remix.mdx (+2 -2)

...and 23 more files

📄 Description

Fix cross-subdomain cookie inheritance in lastLoginMethod plugin

Problem

The lastLoginMethod plugin was bypassing Better Auth's centralized cookie system by using hardcoded cookie attributes, preventing it from inheriting the global crossSubDomainCookies configuration. This meant that when users enabled cross-subdomain cookies in
their Better Auth config, the lastLoginMethod cookie would not work across subdomains (e.g., from auth.example.com to app.example.com).

Solution

  • Replace hardcoded setCookie attributes with proper inheritance from crossSubDomainCookies configuration
  • The plugin now automatically inherits domain settings when crossSubDomainCookies.enabled: true
  • Maintains the same architectural pattern used by other Better Auth plugins (two-factor, admin, passkey)

Changes

  • Core fix: Updated cookie setting logic in lastLoginMethod/index.ts to inherit cross-subdomain settings
  • Documentation: Added cross-subdomain support section with configuration examples
  • Tests: Comprehensive test coverage for cross-subdomain scenarios and custom configurations
  • Backward compatibility: No breaking changes - existing configurations continue to work unchanged

Test Coverage

  • Original functionality (cookie setting, database storage)
  • Cross-subdomain inheritance with explicit domain
  • Cross-subdomain inheritance with auto-detected domain from baseURL
  • Custom cookie prefixes and names
  • Disabled cross-subdomain behavior

Now users can enable cross-subdomain cookies globally and the lastLoginMethod plugin will automatically work across all subdomains without additional configuration.


Summary by cubic

Fixes cross-subdomain cookies in the lastLoginMethod plugin so it inherits Better Auth’s global crossSubDomainCookies settings and works across subdomains. Also adds an admin getUser endpoint and several docs and DX improvements.

  • Bug Fixes

    • lastLoginMethod cookie now inherits domain from advanced.crossSubDomainCookies (or baseURL); keeps custom cookieName behavior.
    • Added tests for cross-subdomain and custom prefixes; updated plugin docs with config examples.
  • New Features

    • Admin: new GET /admin/get-user endpoint with “user:get” permission, error code, and tests.
    • Docs/DX: mobile search on navbar, dynamic code block with copy control, multiple content updates (Auth0 migration guide, Supabase→PlanetScale blog, community plugins), and minor fixes.
    • CI: main branch protection workflow for PR sources.
    • Release: bump packages to 1.3.9.

🔄 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/4571 **Author:** [@lumpinif](https://github.com/lumpinif) **Created:** 9/10/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/last-login-method-cross-subdomain-cookies` --- ### 📝 Commits (10+) - [`dbaae0a`](https://github.com/better-auth/better-auth/commit/dbaae0ab2bc39de87dd4719e37f48e4b94ea2262) docs: hero section alignment with feature section on big screens (#4018) - [`ef481d8`](https://github.com/better-auth/better-auth/commit/ef481d8dcce32d377b412ad1a96ecb8e604c1787) chore: fix broken testomnial link - [`9c46196`](https://github.com/better-auth/better-auth/commit/9c4619626856bd4adbaa4564dd8c110921b1f498) fix(sso): [⚠︎Security] - membership check should be required before allowing users to create sso for an organization - [`5fdf5cd`](https://github.com/better-auth/better-auth/commit/5fdf5cd31a6099ee96e922470eca8adf92c5bc51) chore: update sso docs - [`efa60af`](https://github.com/better-auth/better-auth/commit/efa60af1c2d45a735ed397171bfca513b7e202ca) chore: fix import typo - [`3fd8581`](https://github.com/better-auth/better-auth/commit/3fd858163a393153386c4bb2795abfacd09f091e) docs: hero section alignment with feature section on big screens (#4018) - [`64216f1`](https://github.com/better-auth/better-auth/commit/64216f13250200169717f47225a17df08d2fee2a) chore: fix broken testomnial link - [`28e331a`](https://github.com/better-auth/better-auth/commit/28e331a114ad0cb4e5968c29685c2f7e24187fcc) fix(sso): [⚠︎Security] - membership check should be required before allowing users to create sso for an organization - [`efa0c0b`](https://github.com/better-auth/better-auth/commit/efa0c0ba1b4793d14a2f3f355a82e4086ed4338a) chore: update sso docs - [`95f9e9a`](https://github.com/better-auth/better-auth/commit/95f9e9a39a5b3ca5192dcd174025da1427f01458) chore: fix import typo ### 📊 Changes **43 files changed** (+1753 additions, -177 deletions) <details> <summary>View changed files</summary> ➕ `.github/workflows/main-protect.yml` (+18 -0) 📝 `docs/app/global.css` (+1 -1) 📝 `docs/components/api-method.tsx` (+3 -1) 📝 `docs/components/endpoint.tsx` (+0 -20) 📝 `docs/components/generate-secret.tsx` (+1 -1) ➕ `docs/components/mobile-search-icon.tsx` (+33 -0) 📝 `docs/components/nav-bar.tsx` (+2 -0) 📝 `docs/components/nav-mobile.tsx` (+31 -18) 📝 `docs/components/search-dialog.tsx` (+2 -2) 📝 `docs/components/sidebar-content.tsx` (+34 -17) 📝 `docs/components/ui/code-block.tsx` (+1 -1) ➕ `docs/components/ui/dynamic-code-block.tsx` (+133 -0) ➕ `docs/content/blogs/0-supabase-auth-to-planetscale-migration.mdx` (+370 -0) 📝 `docs/content/docs/authentication/cognito.mdx` (+5 -5) 📝 `docs/content/docs/authentication/google.mdx` (+1 -1) 📝 `docs/content/docs/concepts/client.mdx` (+2 -2) 📝 `docs/content/docs/concepts/users-accounts.mdx` (+2 -2) ➕ `docs/content/docs/guides/auth0-migration-guide.mdx` (+654 -0) 📝 `docs/content/docs/installation.mdx` (+1 -1) 📝 `docs/content/docs/integrations/remix.mdx` (+2 -2) _...and 23 more files_ </details> ### 📄 Description Fix cross-subdomain cookie inheritance in lastLoginMethod plugin Problem The lastLoginMethod plugin was bypassing Better Auth's centralized cookie system by using hardcoded cookie attributes, preventing it from inheriting the global crossSubDomainCookies configuration. This meant that when users enabled cross-subdomain cookies in their Better Auth config, the lastLoginMethod cookie would not work across subdomains (e.g., from auth.example.com to app.example.com). Solution - Replace hardcoded setCookie attributes with proper inheritance from crossSubDomainCookies configuration - The plugin now automatically inherits domain settings when crossSubDomainCookies.enabled: true - Maintains the same architectural pattern used by other Better Auth plugins (two-factor, admin, passkey) Changes - Core fix: Updated cookie setting logic in lastLoginMethod/index.ts to inherit cross-subdomain settings - Documentation: Added cross-subdomain support section with configuration examples - Tests: Comprehensive test coverage for cross-subdomain scenarios and custom configurations - Backward compatibility: No breaking changes - existing configurations continue to work unchanged Test Coverage - ✅ Original functionality (cookie setting, database storage) - ✅ Cross-subdomain inheritance with explicit domain - ✅ Cross-subdomain inheritance with auto-detected domain from baseURL - ✅ Custom cookie prefixes and names - ✅ Disabled cross-subdomain behavior Now users can enable cross-subdomain cookies globally and the lastLoginMethod plugin will automatically work across all subdomains without additional configuration. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes cross-subdomain cookies in the lastLoginMethod plugin so it inherits Better Auth’s global crossSubDomainCookies settings and works across subdomains. Also adds an admin getUser endpoint and several docs and DX improvements. - **Bug Fixes** - lastLoginMethod cookie now inherits domain from advanced.crossSubDomainCookies (or baseURL); keeps custom cookieName behavior. - Added tests for cross-subdomain and custom prefixes; updated plugin docs with config examples. - **New Features** - Admin: new GET /admin/get-user endpoint with “user:get” permission, error code, and tests. - Docs/DX: mobile search on navbar, dynamic code block with copy control, multiple content updates (Auth0 migration guide, Supabase→PlanetScale blog, community plugins), and minor fixes. - CI: main branch protection workflow for PR sources. - Release: bump packages to 1.3.9. <!-- 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-13 09:05:24 -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#13701