Summary
Hive enforces that a verified OIDC email domain can belong to only one organization in the
entire instance. At the same time, both SCIM user provisioning and OIDC sign-in require the
user's email domain to be verified for that specific organization. These two rules are in direct
tension for self-hosted, single-tenant deployments where one company runs Hive and structures
many organizations by line of business, but every user shares one corporate email domain (e.g.
@company.com).
The result: only the first organization to verify company.com can provision or admit
@company.com users. Every other organization is permanently blocked.
Proposal
Add an opt-in, instance-level configuration (env var) listing operator-trusted email domains.
Default is empty → no behavior change (per-org uniqueness preserved for Cloud). When a domain is
listed:
- SCIM email validation (
handleEmailValidation) and OIDC sign-in treat the domain as verified for
any organization, without requiring a per-org oidc_integration_domains row.
- This leaves the strict per-org verification path, the register/verify guards, and the
only_one_verified_domain_name_idx index completely intact — no schema change. Trusted
domains simply short-circuit the verified-domain lookup at the consumer.
Sketch:
// consumer check becomes:
if (isTrustedEmailDomain(email, env.trustedEmailDomains)) return ok;
// else fall back to the existing per-org findVerifiedDomainByOIDCIntegrationIdAndDomainName(...)
This is the least invasive option: it doesn't relax the DB uniqueness constraint (so nothing about
Cloud's guarantees changes) and reframes verification from "per-org domain ownership" to
"instance-level operator-declared trust," which matches the single-tenant reality that the operator
(not any one org) owns the domain.
Summary
Hive enforces that a verified OIDC email domain can belong to only one organization in the
entire instance. At the same time, both SCIM user provisioning and OIDC sign-in require the
user's email domain to be verified for that specific organization. These two rules are in direct
tension for self-hosted, single-tenant deployments where one company runs Hive and structures
many organizations by line of business, but every user shares one corporate email domain (e.g.
@company.com).The result: only the first organization to verify
company.comcan provision or admit@company.comusers. Every other organization is permanently blocked.Proposal
Add an opt-in, instance-level configuration (env var) listing operator-trusted email domains.
Default is empty → no behavior change (per-org uniqueness preserved for Cloud). When a domain is
listed:
handleEmailValidation) and OIDC sign-in treat the domain as verified forany organization, without requiring a per-org
oidc_integration_domainsrow.only_one_verified_domain_name_idxindex completely intact — no schema change. Trusteddomains simply short-circuit the verified-domain lookup at the consumer.
Sketch:
This is the least invasive option: it doesn't relax the DB uniqueness constraint (so nothing about
Cloud's guarantees changes) and reframes verification from "per-org domain ownership" to
"instance-level operator-declared trust," which matches the single-tenant reality that the operator
(not any one org) owns the domain.