Skip to content

IdP-managed tenancy: an unlinked tenant with the org's slug becomes its tenant - #7

Merged
cliftonc merged 1 commit into
mainfrom
idp-adopt-by-slug
Nov 3, 2026
Merged

cliftonc merged 1 commit into
mainfrom
idp-adopt-by-slug

Conversation

@cliftonc

@cliftonc cliftonc commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

On an org's first sign-in, an unlinked tenant whose slug equals the claim's slug is linked to the org (linkTenantBySlug) instead of a second tenant being created. This covers tenants made by hand or before managed tenancy, as with psychiatry-uk → psychiatry-uk-2 in Unwind.

  • A tenant already linked to another org is never taken. Its slug is made unique as before.
  • The link is a single conditional UPDATE … WHERE slug = ? AND external_org_id IS NULL. A concurrent sign-in that links or creates the tenant first is found on the next pass.
  • Owners stay as they are. Manual admin and member rows are adopted, as already happens for any tenant.
  • Decision, recorded in CONCEPTS §2: the issuer's slug is trusted to name the tenant made for it. Admins can still link by id when the slugs differ.

Tests replace "found by its id, never by slug" with: adoption by slug (owner stays, no -2), and a same-slug tenant linked to another org is never taken. pnpm gate passes, apart from kit-manifest locally, which fails only because of untracked docs/unwind/ files.

🤖 Generated with Claude Code

…ts tenant

On an org's first sign-in, the unlinked tenant whose slug is the claim's slug
is linked to the org instead of a second tenant being created. A tenant linked
to another org is never taken.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cliftonc
cliftonc merged commit ab18857 into main Nov 3, 2026
15 checks passed
@cliftonc
cliftonc deleted the idp-adopt-by-slug branch November 3, 2026 05:15
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