MotherDuck’s embedded dashboards can share a service account without sharing tenant rows
The backend must bind the tenant when it creates the embed session. A read-only credential and a dashboard filter are not substitutes for a secure view.
Two customers can open the same embedded MotherDuck dashboard, run the same SQL as the same service account, and see different rows. The difference is not a dashboard filter. The application backend supplies the tenant when it creates the embed session, and a secure view on the Share uses that value to decide which rows the session can read. MotherDuck documents embedding for its Business plan and secure views for Business and Enterprise, including free trials. Embedding Dives · Session context
The service account and the tenant do different jobs
The backend calls MotherDuck with a read/write credential authorized to create embed sessions. The resulting session contains a separate, scoped, read-only token for the target service account, expires after 24 hours, and is the only credential the browser should receive. The service account determines what data the dashboard can access; the secure view determines which rows it gets from the shared table. Read-only describes what the token can do, not which tenant’s rows a query should return. Embedding Dives · Session context
For example, an orders dashboard can use one Share and one target account. The backend takes the tenant from the authenticated viewer’s identity, and the secure view compares tenant_id with session_context('tenant'). The token’s value takes precedence over connection context for any key it sets. If neither source supplies a value, the function returns NULL and that equality matches no rows. But an unset token key is not the same as a locked key: connection context still counts for any key the token leaves unset. Bind every key used by the policy on every token, rather than treating omission as a denial. Embedding Dives · Session context
Test as the viewer, not the Share owner
Before rollout, create two sessions for test tenants with distinct fixture rows, then run the same query through both embedded dashboards. Check which rows and totals each viewer gets, not just whether the iframe loads. Reject a viewer with no authorized tenant before minting the session. If the requirement is to isolate whole databases rather than rows within a shared table, MotherDuck’s embedding guide recommends separate target service accounts scoped to the databases each should access. That is a different design decision from what the dashboard displays. Embedding Dives · Session context
sources
- MotherDuck: Embedding Dives in your web applicationmotherduck.com
- MotherDuck: Filter rows per tenant with session contextmotherduck.com
comments · 0
- EKOS’s pending BIRD submission pairs a SQLite-tuned run with a separate hidden-test scoreDec 3, 2026
- MotherDuck rolls out DuckDB 2.0 and reports faster cold reads, not faster agent answersDec 3, 2026
- Oracle Select AI can use two definitions of the same metric. Source order won’t break the tieDec 3, 2026