Repository navigation
Conversation
…domain-only users Root cause: a data contract has no domains field, so ResourceContext.getDomains() returned null for it and RuleEvaluator.hasDomain() treats a resource without domains as open to everyone. DomainAccessDenyRule therefore never applied to contracts, and DomainAccessAllowRule (allow All when hasDomain()) let a member of one domain read, list, search, patch, delete and create the contract of another domain's table while the table itself was refused to them. Fix: a contract is decided in the current domains of the entity it governs. ResourceContext.getDomains() resolves them for DATA_CONTRACT through the new DataContractRepository.getGovernedEntityDomains, which covers item reads, versions, results, PATCH, PUT, DELETE and the rows of the list and /search endpoints. CreateResourceContext counts them as container domains, so a new contract needs a domain of its entity. A PATCH keeps the governed entity, so a contract cannot be moved onto another domain's entity past that check. Contracts of entities in no domain are decided as before. The resource reuses the repository's target check instead of its own copy. The decision is recorded in ADR:2026-11-27-a-data-contract-is-in-the-domains-of-the-entity-it-governs.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
Code Review ✅ Approved 🔴 High riskChanging domain-based authorization for contract reads, writes, and creation could expose or deny contracts across domain boundaries if entity resolution is wrong. Scopes data contract authorization to the domains of the governed entity, so a domain-only user is refused another domain's contract wherever they are refused its table, and no longer sees it in lists or VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Fixes #38982
A user who holds the DomainOnlyAccessRole in one domain could read, list, search, patch, delete and create the data contract of another domain's table, while the table itself was refused to them. This PR decides a contract in the domains of the entity it governs, so the contract is refused exactly when its table is.
Root cause
dataContract.jsonhas nodomainsfield, soResourceContext.getDomains()returnedentity.getDomains(), which is null for a contract (openmetadata-service/.../security/policyevaluator/ResourceContext.java:420-428on main).RuleEvaluator.hasDomain()returns true for a resource with no domains (RuleEvaluator.java:216-221). SoDomainAccessDenyRule(!hasDomain()) never fired for a contract.DomainAccessAllowRule(allow All whenhasDomain()). That is why DELETE, PUT and POST went through on main, even though the reporter saw a 403 for DELETE on 2.1.1.CreateResourceContext.getContainerDomains()found no container for a contract (CreateResourceContext.java:121-132), sohasDomainForCreatepassed.The fix
ResourceContext.getDomains()resolves a DATA_CONTRACT's domains through the newDataContractRepository.getGovernedEntityDomains: the current domains of the governed entity, inherited ones included. Every endpoint that authorizes throughResourceContextfollows:GET /{id},/name/{fqn},/{id}/odcs,/{id}/odcs/yaml,/name/{fqn}/odcs,/{id}/versions,/{id}/versions/{v},/{id}/results, PATCH, PUT, DELETE and validate. So do the rows ofGET /dataContractsand/dataContracts/search, which go throughreadableRows.CreateResourceContextcounts those domains as the contract's container domains. A member can only create a contract for an entity in their domains (POST, PUT, ODCS import), as ADR:2026-11-03-a-create-is-authorized-against-its-stored-container has it for every other create.DataContractRepository.validatePatchkeeps the storedentity. Without this, a member could PATCH/entityon their own contract and move it onto another domain's table, past the create check. It followsIngestionPipelineRepository.validatePatch, which keeps the pipeline's service. The updater never tracked anentitychange, and the contract's FQN and CONTAINS row kept pointing at the old entity anyway.DataContractResourcereuses the repository's newisSupportedTargetinstead of its own copy.Design choice. I picked option (b), scoping the decision to the governed entity, over (a), an inherited
domainsfield on the schema. Option (b) needs no schema change, no generated-model change, no search-mapping change and no migration. It cannot drift from the entity either: a domain move on a table applies to its contract on the next request. Option (a) would add a stored field that a PATCH or PUT could set apart from the entity's, plus a reindex and a UI surface. The existingResourceContextalready branches by type for domains and parents (DOMAIN,GLOSSARY_TERM,TAG,DATA_PRODUCT), so the contract case sits next to them. The rule is recorded indocs/decisions/2026-11-27-a-data-contract-is-in-the-domains-of-the-entity-it-governs.md.Behavior changes to note
/dataContracts/search./entityis now ignored and the stored entity is kept. Removing/entityused to answer 400.Still open (follow-up, not in this PR). The
dataContractsearch index (/v1/search/query?index=dataContract, its aggregations and the search CSV export) still returns other domains' contracts to a domain-only user when search access control is on. The contract document carries no domains, so search RBAC reads it as domainless. That path is not one of the endpoints in the issue, and it was like this before this PR. Closing it needs a design choice: either index the governed entity's domains and propagate them on every domain change of the entity or its parents, or post-filter the hits asTestCaseSearchMaskerdoes for test cases. The ADR's Consequences names it. Follow-up issue: #39191.Type of change:
High-level design:
N/A, small change. The design choice is above and in the ADR.
Tests:
Use cases covered
GET /v1/dataContracts(paged through to the end) or inGET /v1/dataContracts/search./entitycannot move the member's own contract onto a domain B table.Unit tests
DataContractResourceas having no unit test reference; its change only swaps a private helper for the repository's identical check.ResourceContextTest(5 passed) andRuleEvaluatorTest(32 passed) through the planner, see below.Backend integration tests
openmetadata-integration-tests/for new/changed API endpoints.openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataContractDomainAccessIT.java. It matches the existing*DataContract*ITpattern in the impact map, andplan_local_java_tests.py --check-branchis clean.Fails on main. I ran
DataContractDomainAccessITon the unfixed code (base 730a1e0, the first four test methods):contractOfAnotherDomainsTableIsRefusedOnEveryItemRead: 16 failures, one per path, e.g.GET /v1/dataContracts/51a48444-... must be refused to a member of another domain ==> Expected org.openmetadata.sdk.exceptions.ForbiddenException to be thrown, but nothing was thrown.contractOfAnotherDomainsTableIsLeftOutOfListAndSearch:GET /v1/dataContracts ==> expected: <[..._own_contract, ..._none_contract]> but was: <[..._none_contract, ..._for_contract, ..._own_contract, ..._inh_contract]>, and the same for/search.contractOfAnotherDomainsTableCannotBeChanged: PATCH, DELETE and POST eachExpected ...ForbiddenException to be thrown, but nothing was thrown.contractsOfOwnDomainAndDomainlessTablesStayOpenToTheMember(named...StayReadableAndEditablein that run) passed, as it should on main.The later additions were not run against main: the PUT assertion,
ownContractCannotBeMovedOntoAnotherDomainsTableand the own-domain create. On main,preparestores the patched/entityandDomainAccessAllowRuleallows the PUT, so both fail there by reading of the code.With the fix:
Local Java test run: PASSED
3fa7942c916a(baseorigin/main)--scope full).Command:
The skips are existing
@Disabled/assumption skips in those classes, not new ones. Pending: the full-scope plan (make java_affected, 23 unit classes and 253 ITs, plus PostgreSQL + OpenSearch), which the merge queue runs.Ingestion integration tests
Playwright (UI) tests
Manual testing performed
None beyond the ITs above, which drive the REST API as the reporter's user.
Not tested: the
dataContractsearch index path (see Still open), ODCSPOST/PUT /odcsimports (they authorize through the same two contexts, but no test calls them as a domain member), Postgres + OpenSearch, and Collate (the diff adds public static methods and changes no public signature).UI screen recording:
Not applicable: backend authorization fix, no UI change.
Checklist:
I have read CONTRIBUTING.md (the pre-review gate) and the contributor docs.
My PR title is
Fixes <issue-number>: <short explanation>My PR is linked to a GitHub issue via
Fixes #<issue-number>above.I have commented on my code, particularly in hard-to-understand areas.
For JSON Schema changes: not applicable, no schema change.
For a UI feature or feature task: not applicable.
I have added tests (unit / integration / Playwright as applicable) and listed them above.
Self-review: I reviewed the final diff against
REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below./entitycould move a contract onto another domain's table (nowvalidatePatch, plus an IT case); I also added the PUT and own-domain create cases it asked for. Answered: thedataContractsearch index stays unscoped (see Still open). The second pass found no new 🔴 and rates that one non-blocking once the follow-up issue is linked./v1/dataContractsauthorization (item reads, versions, results, ODCS export, list and/searchrows, POST, PUT, PATCH, DELETE, ODCS import) now decides a contract on its governed entity's domains. The UI contract tab and the ODCS merge import keep working. ThedataContractsearch index, aggregations and search CSV export stay unscoped. Collate is not verified.RowDecisionGatesays rows may differ, and nothing is stored or reindexed.Decision check: adds
docs/decisions/2026-11-27-a-data-contract-is-in-the-domains-of-the-entity-it-governs.md.I have added a test that covers the exact scenario we are fixing.