Repository navigation
Authorize Document Store writes in one place - #38196
Conversation
|
Local Java test run: PASSED — details
Tests run locally
Broader coverage not executed by this focused run
Commandsmvn -B package -pl openmetadata-mcp -am -Dspring-boot.repackage.skip=true -Dtest=PatchEntityToolTest -Dsurefire.failIfNoSpecifiedTests=false
mvn -B verify -pl :openmetadata-integration-tests -am -Dspring-boot.repackage.skip=true -Pmysql-elasticsearch -DintegrationTests.lane=parallel -Dit.test=DocStoreResourceIT -Dfailsafe.failIfNoSpecifiedTests=false -Dtest=NoUnitTestsInThisRun -Dsurefire.failIfNoSpecifiedTests=false |
| @Context SecurityContext securityContext, | ||
| @Valid CreateDocument cd) { | ||
| PrivateDocumentType.requirePublic(cd.getEntityType()); | ||
| requireAdminForEmailTemplates(securityContext, cd.getEntityType()); |
There was a problem hiding this comment.
⚠️ Quality: New email-template auth and entityType-immutability rules lack a record
The description calls this a move of an existing check, but the diff adds two authorization rules. The old DocStoreMapper check only ran in createToEntity (POST/PUT), so PATCH and DELETE on an EmailTemplate used to need nothing beyond normal Document permissions. Now all three DELETE endpoints and both PATCH endpoints call authorizeAdmin, and DocumentRepository.restorePatchAttributes stops any caller, admins included, from changing entityType through PATCH. Without that second rule, a non-admin editor could retype a panel into an email template, so the first rule depends on it. No record in docs/decisions/ states either rule; the only docStore record is about persona layouts. The PR body says "Email templates keep the same admin-only authorization on every Document Store write endpoint" and "PATCH keeps a document's entityType", and the repo squash-merges, so that text won't reach git log. A record would say: "Only admins create, replace, patch or delete a Document whose stored or requested entityType is EmailTemplate, on every docStore write endpoint. A PATCH never changes a Document's entityType, so an edit cannot move a document into or out of the admin-only type." It would be guarded by DocStoreResourceIT#emailTemplatesAreManagedByAdminsOnly and #documentPatchKeepsEntityType.
Add a decision record stating both rules:
# Email templates are managed by admins and a patch keeps a document's type
- **Status:** Accepted
- **Guard:** DocStoreResourceIT#emailTemplatesAreManagedByAdminsOnly, DocStoreResourceIT#documentPatchKeepsEntityType
## Decision
- Every docStore write (POST, PUT, PATCH, DELETE, async DELETE) needs an admin when the requested or stored entityType is EmailTemplate.
- A PATCH never changes a Document's entityType (DocumentRepository.restorePatchAttributes).
Was this helpful? React with 👍 / 👎
Code Review
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
| User user = admin.users().create(createUser); | ||
| return SdkClients.createClient(user.getName(), user.getEmail(), new String[] {}); |
There was a problem hiding this comment.
Test accounts never get deleted.
documentEditor creates a policy, role, and user for each call but never registers them for cleanup. Both new tests call it, so every run leaves six entities on a shared test server, including when later setup fails. The repository review guide requires cleanup for fallible fixture creation. Pass TestNamespace into this helper and register each created entity with trackRoot, or delete them in a failure-safe cleanup block.
Context Used: CLAUDE.md (source)
Describe your changes:
No linked issue.
I moved the email template authorization in the Document Store into
DocStoreResource, so that it sits with the other per-entity checks in the resource layer (as inPersonaResource), instead of inside the mapper.DocStoreResourcehas one helper,requireAdminForEmailTemplates, and every write endpoint calls it.DocStoreMapperonly converts the request and validates the template content.DocumentRepository.restorePatchAttributeskeeps a document'sentityTypeon PATCH, the same way PATCH already keeps the name and FQN.PatchEntityToolthat explains whydocumenthas its own patch flow now names the email template check too.Other document types (knowledge panels, persona pages) behave as before.
Type of change:
High-level design:
N/A, small change in one resource, its mapper and its repository.
Tests:
Use cases covered
entityType.Unit tests
Not added. The change is an HTTP authorization rule, so it is covered end to end by
DocStoreResourceITinstead of a unit test that mocks the authorizer.Backend integration tests
openmetadata-integration-tests/for the changed endpoints.DocStoreResourceIT(2 new tests).Local Java test run: PASSED
633d9c514aa3(baseorigin/main)--scope full).Ingestion integration tests
Playwright (UI) tests
entityType.Visual regression baselines
Manual testing performed
Not applicable: backend-only, covered by
DocStoreResourceIT.UI screen recording:
Not applicable: backend-only change.
Checklist:
Fixes <issue-number>: <short explanation>. No linked issue for this PR.Fixes #<issue-number>above. No linked issue for this PR.REVIEW.md(thepr-checklistskill runs it) and fixed every 🔴 finding, or answered it on the line below.c32a50dc477: reviewed with fresh eyes, no 🔴. One 🟡 on the test fixed in633d9c514aa(the test editor now creates and deletes its own panel), which I reviewed myself.Add fixture cleanup before merging to meet the repository's test requirements.
Findings
Summary
This PR moves email-template write checks into
DocStoreResourceand keeps a document'sentityTypeunchanged during PATCH.Reviews (1) · Last reviewed commit: "Let the docstore test editor create and ..." · Reviewed by Greptile