fix(db): preserve legacy SSO verified domains#35
Open
BunsDev wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the 0056_admin_auth_settings migration to preserve legacy workspace SSO domain verification/enforcement state by backfilling it into the new sso_verified_domain table before removing the legacy JSON keys from settings.auth_config.
Changes:
- Add a legacy backfill that inserts
auth_config.ssoOidc.domain(andssoOidc.enforced) intosso_verified_domain, merging on domain name. - Generate a fallback
verification_tokenfor legacy rows and assign new row IDs during the backfill. - Strip the legacy
ssoOidc.domainandssoOidc.enforcedkeys fromsettings.auth_configafter the backfill.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4672d66 to
7b0f413
Compare
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.
Motivation
sso_verified_domaintable but dropped the data backfill that moved legacysettings.auth_config.ssoOidc.domain+ssoOidc.enforcedinto the new table, which can silently disable workspace SSO hard-binding after upgrade.Description
packages/db/drizzle/0056_admin_auth_settings.sqlthat inserts anyauth_config.ssoOidc.domainrows intosso_verified_domain, preservingverified_atand the workspacessoOidc.enforcedvalue as the per-rowenforcedflag and usingON CONFLICTto merge safely.verification_tokenfor legacy rows when none exists and usegen_random_uuid()for the new rowidto match existing conventions.ssoOidc.domainandssoOidc.enforcedJSON keys after the table-backed rows are created, relying on the migration's existing finalauth_config_versionbump to trigger cache invalidation.Testing
INSERT INTO "sso_verified_domain"backfill, preservation ofenforcedviaEXCLUDED."enforced", and the JSON key stripping, and it passed.git diff --checkto ensure no whitespace/patch issues and it passed.bun testforauth-related suites but they could not run due to missing dependencies (zod) in the environment, so the test run failed for environmental reasons.bun install --frozen-lockfileto populate deps but the environment's registry access returned HTTP 403, so installation and full test runs were blocked.Codex Task