Reject cross-organization Direct Transfer imports
What
Stops Direct Transfer from importing into a different organization when one of the two organizations involved has opted into isolation.
How
Adds validate_destination_organizations! to BulkImports::CreateService#validate!. For each entity, it resolves the destination organization and raises BulkImports::Error.cross_organization_destination when:
- the destination organization differs from
fallback_organization(the request-scoped org, populated fromCurrent.organizationby the controllers), and - either side returns
trueforOrganizations::Isolatable#isolated?.
If neither organization is isolated, the validator is a no-op, so today's flows are unchanged.
The shape mirrors the existing gate in Members::CreatorService#commit_member and lines up with the rollout in epic &17388. Isolation is opt-in via mark_as_isolated!, so the rollback path is mark_as_not_isolated!.
Try it locally
- Two orgs A and B, user in both, destination group in B.
- Rails console:
Organizations::Organization.find_by_path('org-a').mark_as_isolated!. - Signed in scoped to A,
POST /import/bulk_importswithdestination_namespacepointing at B → rejected. mark_as_not_isolated!→ succeeds again.
MR acceptance checklist
- I have evaluated the MR acceptance checklist for this MR.
Closes #595674 (closed). Part of &21584. Related: &17388, &19415.
Edited by Rez