You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(plugin-auth): correct the databaseHooks middleware-bypass claim (#4802) (#4942)
The `databaseHooks` JSDoc justified "use this seam, not an ObjectQL
middleware" with a mechanism claim that no longer holds: better-auth's
adapter "goes through `dataEngine` directly, bypassing the
`ql.registerMiddleware` chain".
Re-verified against main: ObjectQLPlugin registers ONE instance under both
`objectql` and `data`; AuthPlugin hands that same instance to
createObjectQLAdapterFactory; the adapter writes with a plain
`dataEngine.insert(objectName, …)` (no bypass option); and
`ObjectQL.insert()` wraps its body in `executeWithMiddleware()`, filtered
only by object name. The chain and the lifecycle hooks do fire.
The rule is unchanged — user-lifecycle invariants belong in
`user.create.after` — but the reason is now ADR-0093 D2 (one owner on the
one seam every creation path flows through). The narrower surviving fact is
written down in place of the false one: adapter writes carry
`context.isSystem: true`, so authorization middlewares early-return by
design. The stale sentence is refuted in place rather than deleted because
it was copied into cloud's agent-facing docs (cloud#1012 / cloud#1022).
Comments only; no runtime behaviour change.
Claude-Session: https://claude.ai/code/session_018iARDqtrhQgz6fVHDeDkbQ
Co-authored-by: Claude <noreply@anthropic.com>
docs(plugin-auth): the `databaseHooks` doc comment no longer claims better-auth's adapter bypasses the ObjectQL middleware chain (#4802). The option's JSDoc in `auth-manager.ts` (and its two sibling copies — the wiring comment beside `composeDatabaseHooks`, and `AuthPluginOptions.databaseHooks` in `auth-plugin.ts`) justified "use `databaseHooks`, not an ObjectQL middleware" with a mechanism claim that no longer holds: *better-auth's adapter goes through `dataEngine` directly, bypassing the `ql.registerMiddleware` chain*.
5
+
6
+
Re-verified hop by hop against `main`: `ObjectQLPlugin` registers **one** engine instance under both service names (`registerService('objectql', this.ql)` and `registerService('data', this.ql)`, and nothing else in the repo registers `data`); `AuthPlugin` passes exactly that instance to `createObjectQLAdapterFactory`; the adapter writes with a plain `dataEngine.insert(objectName, …)` — there is no bypass or skip-middleware option to pass; and `ObjectQL.insert()` wraps its body in `executeWithMiddleware()`, whose only filter is the object name. So `ql.registerMiddleware(fn, { object: 'sys_user' })`**does** fire for better-auth's writes, and so do the engine's `beforeInsert`/`afterInsert` hooks — the SCIM identity-source stamp in `auth-plugin.ts` is built on precisely that.
7
+
8
+
The **rule is unchanged** — user-lifecycle invariants still belong in `user.create.after`, not in a `sys_user` middleware — but the reason is now the one that is actually true: **ADR-0093 D2**, one owner for the invariant on the one seam every creation path already flows through (self-signup, admin create-user, import, SSO JIT). The narrower fact that survives is written down instead of the false one: adapter writes carry `context.isSystem: true` (`withSystemContext`, pinned by `objectql-adapter.test.ts`), so every *authorization* middleware — security, sharing, the ADR-0092 identity write guard — early-returns by design; a middleware that gates on `isSystem` sees nothing, one that does not, runs.
9
+
10
+
The stale sentence is **refuted in place rather than deleted**, because it had been copied into cloud's agent-facing docs and had already killed the middleware option in two rounds of design work there (cloud#1012, handed over as cloud#1022). A reader arriving from one of those copies needs to see the claim named and corrected; a silent deletion would leave them assuming the framework comment is the stale one.
11
+
12
+
Comments only — no runtime behaviour changes, nothing released.
0 commit comments