fix: persist tenant identity and preserve Personal workspace access - #447
Conversation
…izations Resolve verified Clerk principals once before dashboard reads and writes. Preserve stable tenant IDs, reject ambiguous legacy matches, and support nested session organization claims. Add signed-session and migration regression coverage for #389. Co-Authored-By: Duyet Le <me@duyet.net> Co-Authored-By: duyetbot <bot@duyet.net>
Remove automatic membership selection, preserve separate personal and team scopes, and test switching to Personal through the rendered control. Co-Authored-By: Duyet Le <me@duyet.net> Co-Authored-By: duyetbot <bot@duyet.net>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's GuideThe PR replaces string-derived dashboard tenancy with persisted, verified Clerk-principal bindings to stable internal tenant IDs, migrates only recognizable legacy identities in place, hardens claim parsing and conflict handling, and restores an explicit Personal/team workspace switcher with extensive isolation and compatibility regression coverage. Sequence diagram for verified tenant resolutionsequenceDiagram
participant Clerk
participant Auth as clerkDashboardAuth
participant Claims as normalizeSessionClaims
participant DB as organization_identities
participant Tenant as resolveTenant
participant Route as Dashboard route
Clerk->>Auth: verifyDashboardSession
Auth->>Claims: normalizeSessionClaims
Claims-->>Auth: DashboardPrincipal
Auth->>Tenant: resolveTenant(principal)
Tenant->>DB: Lookup principal binding
alt binding exists
DB-->>Tenant: organization_id
else binding missing
Tenant->>DB: Atomically create organization and binding
DB-->>Tenant: organization_id
end
Tenant-->>Auth: tenantId
Auth->>Route: Continue with tenantId
Route->>Route: Scope project reads and writes by tenantId
Entity relationship diagram for tenant identity bindingserDiagram
ORGANIZATIONS {
text id PK
text clerk_org_id
}
ORGANIZATION_IDENTITIES {
text principal_kind
text clerk_subject
text organization_id FK
}
ORGANIZATIONS ||--o| ORGANIZATION_IDENTITIES : has_stable_binding
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Summary
Closes #389.
defaultor unknown legacy data automatically; document operator audit and verified recovery.Verification
Deployment note
Run the documented unbound-organization audit after migration. Ambiguous legacy rows require independently verified ownership; this PR does not access or modify production data. No release-please changes.
Co-Authored-By: Duyet Le me@duyet.net
Co-Authored-By: duyetbot bot@duyet.net
Summary by Sourcery
Persist verified workspace identities and use them consistently for tenant authorization while preserving explicit, isolated Personal workspace access.
New Features:
Bug Fixes:
Enhancements:
Build:
Deployment:
Documentation:
Tests: