Skip to content

fix(auth): scopeBy fields with other names take the caller's tenant - #167

Merged
cultron merged 1 commit into
mainfrom
fix/scope-context-fallback
Oct 29, 2026
Merged

cultron merged 1 commit into
mainfrom
fix/scope-context-fallback

Conversation

@cultron

@cultron cultron commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Found while writing the Supabase migration guide. Imported schemas keep source column names such as orgId, and scopeBy: "orgId" then refused every request under 0.45.x. The scope guard and @CrudAuth looked up request.orgId, which no auth guard sets. With auth configured they now fall back to request.auth[field], then request.auth.workspaceId.

Tests: the auth smoke adds a Note entity scoped on orgId. A create stores the caller's tenant, and the other tenant can't read or list it. All three languages pass locally, and 515 unit tests pass.

ScopeGuard and @CrudAuth looked the tenant up under the scopeBy field's own
name, which the auth guards only set for workspaceId and organizationId. An
imported schema scoped on orgId refused every request. With auth configured,
both now fall back to the matching auth context field, then the auth tenant.
The auth smoke covers a Note entity scoped on orgId.
@cultron
cultron merged commit 801e34d into main Oct 29, 2026
8 checks passed
@cultron
cultron deleted the fix/scope-context-fallback branch October 29, 2026 03:52
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