.NET/Python: Purview: prefer token principal for user identity - #6693
Merged
eoindoherty1 merged 2 commits intoJun 24, 2026
Merged
Conversation
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Purview middleware identity resolution to prefer the authenticated token’s user principal (when present), with validated fallbacks for app-token scenarios, and aligns the .NET content activities route with the documented /users/{userId}/... Graph endpoint.
Changes:
- Python: always inspect token info up front and use token
user_idbefore considering provided/message fallbacks; update docs and tests accordingly. - .NET: validate message-supplied
userIdfallbacks as GUIDs, prefer tokenUserIdover message metadata, and add regression tests for precedence + scope-location matching. - .NET: fix
SendContentActivitiesAsyncto call/users/{userId}/dataSecurityAndGovernance/activities/contentActivitiesand update the unit test.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| python/packages/purview/tests/purview/test_processor.py | Updates tests to account for unconditional token inspection and token-user precedence. |
| python/packages/purview/README.md | Updates guidance to clarify user-token vs app-token user identity behavior. |
| python/packages/purview/agent_framework_purview/_processor.py | Changes identity resolution order to prefer token principal, then validated fallbacks. |
| dotnet/tests/Microsoft.Agents.AI.Purview.UnitTests/ScopedContentProcessorTests.cs | Adds/updates tests for token precedence, GUID validation, and location matching. |
| dotnet/tests/Microsoft.Agents.AI.Purview.UnitTests/PurviewClientTests.cs | Updates expected content activities URL to the /users/{userId}/... route. |
| dotnet/src/Microsoft.Agents.AI.Purview/ScopedContentProcessor.cs | Implements token-first user identity resolution and GUID validation for message fallbacks. |
| dotnet/src/Microsoft.Agents.AI.Purview/README.md | Updates docs describing token-principal precedence and app-token expectations. |
| dotnet/src/Microsoft.Agents.AI.Purview/PurviewClient.cs | Fixes content activities endpoint construction to use /users/{userId}/.... |
taisirhassan
force-pushed
the
purview-token-identity-fixes
branch
from
June 23, 2026 23:03
7c77e88 to
11e61d4
Compare
Align Purview middleware identity resolution so user-token principals are preferred before supplied message identities, while app-token flows continue to use validated fallback user IDs. Also fix the content activities user route and add regression coverage for identity precedence and route construction. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
taisirhassan
force-pushed
the
purview-token-identity-fixes
branch
from
June 23, 2026 23:06
11e61d4 to
927cd8c
Compare
Rishabh4275
approved these changes
Jun 23, 2026
…unit test for empty token user ID
eoindoherty1
approved these changes
Jun 23, 2026
darkness11111
approved these changes
Jun 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
Purview middleware needs consistent identity resolution across .NET and Python. User-token credentials should evaluate policy for the authenticated token principal, while app-token flows should continue to support supplied end-user IDs for policy scoping.
This also aligns the content activities route with the other Purview Graph user routes.
Description & Review Guide
What are the major changes?
userIdfallback values to parse as GUIDs, matching Python validation./users/{userId}/....What is the impact of these changes?
What do you want reviewers to focus on?
ScopedContentProcessor/_processor.py.PurviewClientTests.Related Issue
No public issue. Security hardening and parity fix for Purview middleware.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.