feat(lakebase): OBO pool manager for per-user Lakebase connections#343
Draft
feat(lakebase): OBO pool manager for per-user Lakebase connections#343
Conversation
Add LakebasePoolManager to the AppKit connector layer, enabling On-Behalf-Of (OBO) authentication where each user gets their own pg.Pool with individual OAuth token refresh. This enables Row-Level Security (RLS) in Lakebase based on current_user identity. Changes: - Add createLakebasePoolManager() in appkit connector (pool-manager.ts) - Export LakebasePoolManager type and factory from @databricks/appkit - Update dev-playground raw driver example with RLS policy and OBO routes - GET/POST /raw/my-products use per-user pools (RLS enforced) - GET/POST /raw/products remain on SP pool (RLS bypassed) Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
Add console logging to OBO route handlers so pool creation/reuse is visible in app logs. Add hasPool() to LakebasePoolManager interface. Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
- Remove unused plugins (files, genie, jobs, serving) to avoid resource resolution errors - Add database resource env var mappings in app.yaml - Simplify lakebase plugin to raw driver example only - Downgrade @databricks/lakebase to 0.2.0 for npm registry compat Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
- Change id from SERIAL to UUID with gen_random_uuid() default to avoid sequence permission issues with OBO users - Grant schema/table access to PUBLIC so OBO users can SELECT/INSERT - Add OboProductsPanel component with full email visibility - Add debug-token endpoint and use x-forwarded-email header Signed-off-by: Pawel Kosiec <pawel.kosiec@databricks.com>
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.
Caution
POC / Do Not Merge — This is a prototype for exploring Lakebase OBO authentication and RLS. Not ready for production.
Summary
LakebasePoolManagerto the AppKit connector layer for managing per-user Lakebasepg.Poolinstancesx-forwarded-access-tokencurrent_user, so the database enforces access control/raw/my-products) alongside existing SP routes (/raw/products)How it works
createLakebasePoolManager(baseConfig)returns a manager that caches pools by key (user email)x-forwarded-emailheader and token fromx-forwarded-access-tokenpoolManager.getPool(userEmail, { workspaceClient, user })returns a cached or new poolproductstable filters rows based oncurrent_userSP routes (table owner) bypass RLS and see all rows. OBO routes see only the user's rows.
Testing setup (eng-nephos-dust-oregon)
1. Create a role for each test user
Go to the Roles & Databases page and create a role matching the user's email (e.g.
pawel.kosiec@databricks.com).2. Grant permissions
Open the SQL Editor and run:
3. Test the app
App URL: https://pk-lakebase-test-3111837193506155.staging.aws.databricksapps.com/lakebase
GET /api/lakebase-examples/raw/debug-tokenshows forwarded headersTest plan
pnpm buildpassespnpm -r typecheckpassespnpm check:fixpassespnpm test— all 1817 tests pass