Repository navigation
feat(auth): honour the owner's Better Auth database and sign-in methods (#1052 S5) - #1057
Merged
Merged
Conversation
…ds (#1052 S5) auth({database}) also takes the owner's own Better Auth database (an adapter, dialect or pool), passed to Better Auth unchanged. With one, the SQLite-only lock, WAL/file checks, table check and migrations do not apply, activation logs one warning naming what is the owner's, and urlcode-auth migrate, create-user and find-user refuse. A hermetic run serves the owner's testDatabase factory's isolated database and is refused without one; it never falls back to live data. Seeds go through Better Auth's internal adapter. Email and password is a default rather than forced. Part of #1052. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimhoyd
enabled auto-merge (squash)
September 30, 2026 15:06
…generate references Co-Authored-By: Claude Opus 5.5 <[email protected]>
jimhoyd
added a commit
that referenced
this pull request
Sep 30, 2026
…1061) A resolved merge committed packages/auth/CHANGELOG.md with its conflict markers still in it (via #1057), and no check failed: code conflicts break the typecheck, but Markdown, JSON and YAML conflicts passed everything. Removed from main by #1055. Co-authored-by: Claude Opus 5.5 <[email protected]>
This was referenced Sep 30, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1052 (slice S5: Better Auth bring-your-own database).
What changes
auth({database})takes either the bundled SQLite file's path (as before) or the owner's own Better Auth database (anything Better Auth'sdatabaseoption accepts). An owner database goes to Better Auth unchanged.betterAuth.databaseis refused and points todatabase.holdServerLock, no WAL/permission/network-FS checks, nopendingMigrationscheck and no migrations. Better Auth's owncheckSchemastill runs when its adapter has one. Activation emits oneextension_warning(ownerDatabaseWarning) that names what becomes the owner's responsibility: schema and migration state, backups, single-writer or multi-server rules, and access control.urlcode-auth migrate/create-user/find-userrefuse with exit 2 and a clear message whiledata/auth.owner-databaseexists.host()writes that marker on a non-hermetic load with an owner database and removes it when host.mjs switches back to SQLite. The CLI cannot read host.mjs, so before the first non-hermetic host load (validate with a pin, dev, serve) it cannot know the owner's choice. That limitation is in the docs.auth({testDatabase: ({data}) => <fresh db>})is called once per run. Without it, activation refuses (hermeticOwnerDatabaseRefusal). If it returns the live database object, activation also refuses. A hermetic registration never servesdatabase.internalAdapter.createUser+linkAccount(Better Auth's API, with hooks), so they work on any adapter.emailAndPassword.enabled: false,/sign-in/emailand/change-passwordanswer 404, andsignUp: trueand an auth seed are refused.Contract check with an owner database (memoryAdapter test)
auth_unavailableon a storage failure on the gate,/list-sessionsand/sign-out, with noSet-Cookie. The session survives an unconfirmed sign-out.Tests
New
packages/auth/test/owner-database.test.tsuses Better Auth's upstreammemoryAdapter. It covers an owner-database site serving sign-in (plus the warning and the 503/sign-out/allowlist/bounds contract), the hermetic refusal without an isolated database, the hermetic run with one (the seed goes into the test database and the live one stays untouched), email/password disabled, and the CLI refusal and its lifting. All existing SQLite-path tests pass unchanged.npm run verify,npm run test:package,npm run audit:packages(auth: 28372 packed / 91455 unpacked / 14 files, within budget) andnpm run test:proofpass locally.Docs
Auth README (new "Your own database" section), SECURITY, CHANGELOG and llms.txt; root llms.txt; RIM-EXT-HERMETIC-001 card (plus the fixture); EXTENSIONS hermetic section; READINESS test data; FRAMEWORK table.
🤖 Generated with Claude Code