Skip to content

fix 371 trino impersonation - #397

Draft
Bohreromir wants to merge 8 commits into
mainfrom
worktree-fix-371-trino-impersonation
Draft

Bohreromir wants to merge 8 commits into
mainfrom
worktree-fix-371-trino-impersonation

Conversation

@Bohreromir

Copy link
Copy Markdown
Member

No description provided.

input: false on user.additionalFields.username also made better-auth drop
the field from the OIDC provider profile, so new users had no username and
Trino ran their queries as 'anonymous'. Allow the write only from the OIDC
callback via database hooks instead, which still rejects rewrites through
/update-user (#330).
…ame (#371)

Fall back to 'anonymous' only when nobody is signed in (OIDC disabled). A
signed-in user without a username now gets a logged error and a 500, so a
lost username claim can no longer go unnoticed.
The mock Trino now records X-Trino-User, so the query API test can check the
impersonated user matches the signed-in user.
#371)

- Set overrideUserInfo on the OIDC provider, so a changed Trino user
  claim reaches existing users on their next login, not only new ones.
- Drop the `|| ''` fallback for the username: better-auth rejects a
  sign-in without email before creating the user, so an empty username
  is never stored.
- Split findTrinoUser (returns null) from getTrinoUser (fails with 500).
  The connection-test action now returns a localised form error
  (trino_user_missing) instead of the error page.
- Mock OIDC server: a test can sign in as a fixed user with chosen
  claims via the mock_oidc_user cookie.
- E2E: a later login updates the username from the claim.
@Bohreromir Bohreromir self-assigned this Oct 21, 2026
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 64.89% 8700 / 13407
🔵 Statements 63.98% 11704 / 18291
🔵 Functions 66.3% 2790 / 4208
🔵 Branches 55.12% 4998 / 9067
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/lib/server/auth-schema.ts 36.84% 100% 0% 43.75% 13, 26-35, 46-59, 72-75, 78-81, 83-88, 90-95
src/lib/server/auth-utils.ts 100% 100% 100% 100%
src/lib/server/auth.ts 66.66% 43.75% 44.44% 76% 11, 12, 13, 16, 101-124
src/routes/(app)/api/trino/catalog/+server.ts 100% 95% 100% 100%
src/routes/(app)/api/trino/completion/metadata/+server.ts 100% 96.29% 100% 100%
src/routes/(app)/api/trino/query/+server.ts 100% 100% 100% 100%
src/routes/(app)/trino/+page.server.ts 0% 0% 0% 0% 24-104
Generated in workflow #1131 for commit 2adba17 by the Vitest Coverage Report Action

The field holds the Trino user we impersonate, not a login name. Rename the
column to trino_user in the initial migration; there is no release yet, so no
new migration is needed.
@Bohreromir
Bohreromir force-pushed the worktree-fix-371-trino-impersonation branch from 8b6e575 to 2adba17 Compare October 21, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant