fix: validate domain uniqueness across organizations#10
Merged
Conversation
The WorkOS API does not enforce domain uniqueness at the API level — uniqueness is only enforced via DNS TXT verification, which this provider bypasses by setting domains as pre-verified. This could lead to multiple organizations silently sharing the same domain, causing unpredictable SSO routing and nondeterministic data source lookups. - Add ListOrganizationsByDomain client method exposing all matches - Error in GetOrganizationByDomain when multiple orgs share a domain - Validate domain uniqueness on resource create and update, erroring if a domain is already assigned to a different organization Closes #8 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
Any chance of a new published version? Thanks for the work. |
Contributor
Author
|
Hey @danielloader — we've just raised #11 which adds automated release management via release-please. Once that's merged, pushing to main will automatically create a release PR with version bumps and changelog. Merging that release PR will trigger goreleaser to build and publish to the Terraform registry. All CI checks are passing on #11, so we should have a new published version shortly after it lands. Thanks for the nudge! 🙏 |
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.
Summary
Addresses #8 — the WorkOS API does not enforce domain uniqueness at the API level. Uniqueness is only enforced via DNS TXT verification, which this provider bypasses by setting domains as pre-verified (
state: "verified"). This could allow multiple organizations to silently share the same domain, causing:data.workos_organizationdomain lookup would silently return whichever org appeared first in the API responseChanges
Client layer (
internal/client/organizations.go):ListOrganizationsByDomain()— returns all organizations matching a domain (exposes the full list)GetOrganizationByDomain()— now returns a clear error when multiple organizations share the same domain, directing users to look up by ID insteadResource (
internal/provider/resource_organization.go):validateDomainUniqueness()helper that checks each domain against existing organizations before create/updateTest plan
TestAccOrganizationResource_Basic,TestAccOrganizationResource_WithDomains,TestAccOrganizationDataSource_ByDomain)🤖 Generated with Claude Code