Repository navigation
Fixes #29999: Propagate active persona request context - #30000
Conversation
✅ PR checks passedThe linked issue has a description and all required Shipping project fields set. Thanks! |
🟡 Playwright Results — all passed (36 flaky)✅ 4500 passed · ❌ 0 failed · 🟡 36 flaky · ⏭️ 96 skipped
🟡 36 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 |
Code Review ✅ Approved 2 resolved / 2 findingsImplements active persona propagation via API request headers and cached subject context, ensuring consistent authorization across the backend and MCP tools. Persona cache invalidation and user-context aggregation have been successfully resolved. ✅ 2 resolved✅ Edge Case: Persona cache invalidation silently skips refs without name
✅ Quality: Duplicate affected-user aggregation in updateUsers
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
|
|
Code Review ✅ Approved 2 resolved / 2 findingsImplements active persona propagation via API request headers and cached subject context, ensuring consistent authorization across the backend and MCP tools. Persona cache invalidation and user-context aggregation have been successfully resolved. ✅ 2 resolved✅ Edge Case: Persona cache invalidation silently skips refs without name
✅ Quality: Duplicate affected-user aggregation in updateUsers
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |



Describe your changes:
Fixes #29999
Propagates the UI-selected persona ID on every API request and carries it through authentication into a lazily validated
SubjectContext, using cached direct, inherited, and default persona references with default fallback and no per-request header lookup.AI persona context and membership checks now consume cached subject data, persona mutations invalidate only affected user-context entries where possible, and invalid header logging is sanitized and bounded.
In-server MCP tool execution now preserves the incoming
CatalogSecurityContext; this carries the active persona and, as a correctness change, also propagatesimpersonatedUserso impersonated MCP calls receive the normal impersonation authorization checks.Type of change:
High-level design:
selectedPersona.id→X-OpenMetadata-PersonaAxios interceptor → authentication filtersCatalogSecurityContextfield plus a request-scoped ThreadLocal fallback for wrapped Jersey contextsSubjectContextagainst the 15-minute cached direct, inherited, and default personasTests:
Use cases covered
Unit tests
JwtFilterTest,SubjectContextTest,SubjectCacheTest,DefaultAuthorizerTest, andImpersonationCleanupFilterTestwithActivePersonaHeader.test.ts(2/2 passing)Backend integration tests
ActivePersonaHeaderITIngestion integration tests
Playwright (UI) tests
Manual testing performed
Not performed because the local Docker-backed stack is unavailable
UI screen recording / screenshots:
Not applicable — this changes request headers only and has no visual UI changes
Checklist:
Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.Improvement checklist
Greptile Summary
This PR carries the selected persona through requests and server-side subject context. The main changes are:
CatalogSecurityContext.Confidence Score: 5/5
This looks safe to merge.
Important Files Changed
Comments Outside Diff (2)
openmetadata-service/src/main/java/org/openmetadata/service/mcpclient/McpClientService.java, line 568-572 (link)When Jersey passes a wrapped
SecurityContext, this fallback builds a newCatalogSecurityContextwithout the request persona or impersonated user. Tool authorization then sees aCatalogSecurityContextand skips the ThreadLocal fallback, so wrapped MCP calls can run with the wrong persona context and without the normal impersonation checks.openmetadata-service/src/main/java/org/openmetadata/service/mcpclient/McpClientService.java, line 568-572 (link)When MCP receives a wrapped
SecurityContext, this fallback creates a newCatalogSecurityContextwith noimpersonatedUseroractivePersona. Downstream authorization then sees aCatalogSecurityContextand reads those null fields directly, so it never uses the request-scoped fallbacks that were set by the filters. A wrapped impersonated MCP request can therefore execute tool authorization without the normal impersonation check and without the selected persona.Reviews (4): Last reviewed commit: "Preserve security hints in wrapped MCP c..." | Re-trigger Greptile
Context used (3)