Repository navigation
Restrict cross-user follower changes - #32322
Conversation
❌ 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 |
There was a problem hiding this comment.
Pull request overview
This PR addresses GHSA-962g-h22r-w7hg by preventing non-admin users from adding/removing followers on behalf of other users, centralizing the cross-user authorization guard in EntityResource and routing all entity follower endpoints through it.
Changes:
- Added guarded
addFollowerInternal/deleteFollowerInternalhelpers to enforce “self-only unless admin” follower mutations. - Updated follower endpoints across entity resources to delegate to the guarded helpers (eliminating direct resource → repository follower mutations).
- Added integration tests ensuring non-admin cross-user follower add/remove attempts are rejected and do not mutate state.
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| openmetadata-service/src/main/java/org/openmetadata/service/resources/EntityResource.java | Introduces shared follower mutation helpers + centralized authorization guard. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/topics/TopicResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/storages/ContainerResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/storage/StorageServiceResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/security/SecurityServiceResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/searchIndexes/SearchServiceResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/pipeline/PipelineServiceResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/mlmodel/MlModelServiceResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/metadata/MetadataServiceResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/messaging/MessagingServiceResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/mcp/McpServiceResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/llm/LLMServiceResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/ingestionpipelines/IngestionPipelineResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/drive/DriveServiceResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/database/DatabaseServiceResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/dashboard/DashboardServiceResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/services/apiservices/APIServiceResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/searchindex/SearchIndexResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/query/QueryResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/pipelines/PipelineResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/mlmodels/MlModelResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/metrics/MetricResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/knowledge/KnowledgePageResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/drives/WorksheetResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/drives/SpreadsheetResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/drives/FileResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/drives/DirectoryResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/domains/DomainResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/domains/DataProductResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/datamodels/DashboardDataModelResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/TableResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/StoredProcedureResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/DatabaseSchemaResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/databases/DatabaseResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/dashboards/DashboardResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/charts/ChartResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/apis/APIEndpointResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/PromptTemplateResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/McpServerResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/LLMModelResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/AIGovernancePolicyResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-service/src/main/java/org/openmetadata/service/resources/ai/AIApplicationResource.java | Delegates follower add/remove endpoints to the shared guarded helpers. |
| openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.java | Adds IT coverage for non-admin cross-user follower mutation rejection + non-mutation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
✅ Playwright Results — workflow succeededValidated commit ✅ 997 passed · ❌ 0 failed · 🟡 5 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 1h 24m 31s ⏱️ Max setup 4m 35s · max shard execution 19m 36s · max shard-job elapsed before upload 23m 3s · reporting 7s 🌐 203.95 requests/attempt · 2.42 app boots/UI scenario · 34.27% common-shard skew Optimization targets still in progress:
🟡 5 flaky test(s) (passed on retry)
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 43 out of 43 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.java:248
- This test name is prefixed with
put_but it exercises the DELETE follower endpoint; renaming it keeps the method-name convention (HTTP verb prefix) consistent and avoids confusion when scanning test failures.
void put_deleteFollowerForAnotherUserAsAdmin_200(TestNamespace ns) {
buildReadBundle used the read-bundle cache for every non-deleted read, ignoring UNCACHED_ENTITY_TYPES (user, task, workflow*, bot, domain, dataProduct). For those types a mutation followed by an immediate re-read — e.g. the follower add/delete then fetch in this PR's DataProductResourceIT — could serve a stale cached bundle. Without this, the follower authorization tests fail under a cache-enabled deployment (postgres-elasticsearch-redis / postgres-opensearch integration lanes) with `expected <false> but was <true>` after a delete. Gate the read-bundle cache on isCacheableEntityType(entityType) so uncached types take the already-supported bundleCache == null path and always reflect the current entity_relationship state. Required for the follower tests to pass on the Redis/OpenSearch lanes (documents why this caching change is part of the security fix, per reviewer request).
There was a problem hiding this comment.
🟢 Approval recommended
The centralized guard enforces the intended authorization/validation behavior and the added integration tests cover the key success/denial cases.
Review details
Suppressed comments (2)
Previously missed (1) — in code that hasn't changed since the last review.
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.java:248
- Test name prefix uses
put_but the behavior under test is deleting another user’s follower relationship (this test callsHttpMethod.DELETE). Renaming to adelete_...-prefixed name aligns with the existing naming convention in this file.
openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.java:235
- Test name prefix uses
put_but this test primarily validates DELETE follower behavior (and callsHttpMethod.DELETE). Renaming it to adelete_...-prefixed name keeps naming consistent with other tests in this class and makes targeted test runs by method name less confusing.
void put_deleteFollowerForSelf_200(TestNamespace ns) {
- Files reviewed: 44/44 changed files
- Comments generated: 0 new
- Review effort level: Lite
…_ prefix The two round-trip tests exercise the DELETE follower endpoint (add is setup), so name them with the delete_ verb prefix to match the method-name convention (addresses the Copilot review comment).
There was a problem hiding this comment.
🟢 Approval recommended
The centralized guard enforces the intended authorization behavior consistently across resources, the cache fix aligns with existing cacheability gating, and the added integration tests cover the critical scenarios.
Review details
- Files reviewed: 44/44 changed files
- Comments generated: 0 new
- Review effort level: Lite
There was a problem hiding this comment.
🟢 Approval recommended
The authorization guard is centralized and consistently applied, the cache edge case is addressed, and integration tests cover the key allowed/denied behaviors plus the null-input 400 response.
Review details
- Files reviewed: 44/44 changed files
- Comments generated: 0 new
- Review effort level: Lite
Code Review ✅ Approved 1 resolved / 1 findingsRestricts cross-user follower mutations to admin users while allowing non-admin users to manage only their own follower state. All 41 entity-resource add/delete follower pairs now delegate through a shared authorization guard that validates user IDs and enforces role-based access control. Also includes a required cache fix for ✅ 1 resolved✅ Bug: Follower guard blocks non-admin bots from cross-user mutations
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
There was a problem hiding this comment.
🟢 Approval recommended
The authorization guard is centralized and consistently applied across follower endpoints, the cache fix aligns behavior with documented uncached entity types, and integration tests cover the key permission and validation cases.
Review details
- Files reviewed: 44/44 changed files
- Comments generated: 0 new
- Review effort level: Lite
|



Describe your changes:
Follower mutations now allow users to change only their own follower state while preserving admin management, and all 41 entity-resource add/delete follower pairs delegate through the shared authorization guard. Missing follower user IDs are rejected with a deterministic 400 response before authorization or persistence.
Type of change:
High-level design:
EntityResourceowns guarded add/delete follower helpers that validate the requested user ID, compare it with the authenticated subject using null-safe equality, and require admin authorization for cross-user mutations. Every current follower endpoint delegates to those helpers before calling the repository, keeping authorization in the resource layer and preserving configuredAuthorizerbehavior. The repository contract, response payloads, self-follow behavior, and admin compatibility remain unchanged; no schema, migration, or rollout work is required.Note on the included cache fix (
EntityRepository.buildReadBundle):This PR also carries a required one-line cache fix:
buildReadBundleused the read-bundle cache for every non-deleted read, ignoringUNCACHED_ENTITY_TYPES(user, task, workflow*, bot, domain, dataProduct). For those types a mutation followed by an immediate re-read — exactly the follower add/delete thenhasFollowerfetch inDataProductResourceIT— could serve a stale cached bundle. Without it, the follower tests fail on the cache-enabled integration lanes (postgres-elasticsearch-redis,postgres-opensearch) withexpected <false> but was <true>after a delete. The fix gates the read-bundle cache onisCacheableEntityType(entityType)so uncached types always reflect currententity_relationshipstate. It is not separable from this security fix — it is what makes the follower tests pass on cache-enabled deployments.Tests:
Use cases covered
userId is required.Unit tests
Backend integration tests
openmetadata-integration-tests/for the changed API behavior.openmetadata-integration-tests/src/test/java/org/openmetadata/it/tests/DataProductResourceIT.javaIngestion integration tests
Playwright (UI) tests
Manual testing performed
mvn -pl openmetadata-integration-tests -am package -Dtest='DataProductResourceIT#put_addFollowerForAnotherUser_403+delete_removeFollowerForAnotherUser_403+put_deleteFollowerForSelf_200+put_deleteFollowerForAnotherUserAsAdmin_200+put_addFollowerWithNullUserId_400' -Dsurefire.failIfNoSpecifiedTests=false; the full 11-module reactor passed.mvn spotless:applyandmvn spotless:check; all 16 modules passed.UI screen recording / screenshots:
Not applicable — no UI changes.
Checklist:
Fixes <issue-number>: <short explanation>— N/A: this security fix links the private GHSA instead of a public issue.Fixes #<issue-number>above — N/A: publishing a separate issue would disclose the private advisory.