-
Notifications
You must be signed in to change notification settings - Fork 65
Update Deduplicate and Authorization functionality #513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…n internal class for simplicity
…uth flow is breaking between Begin and Pending states
…microsoft/Agents-for-net into users/tracyboehrer/blobs-dedupe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances deduplication logic for OAuth token exchanges across multiple storage implementations (Blobs, Memory, and CosmosDB) and improves authorization flow handling, particularly for consent-required scenarios.
Key changes:
- Adds
IStorageExtinterface with conditional write support (IfNotExists) for deduplication - Refactors deduplication logic to use storage-based checks rather than ETag-based tracking
- Improves OAuth flow error handling for cancelled and consent-required scenarios
Reviewed Changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| CosmosDbPartitionedStorageTests.cs | Updates test mocks to properly return responses from CreateItemAsync and UpsertItemAsync |
| BlobsStorageTests.cs | Refactors mock setup to return proper responses from UploadAsync |
| TokenTests.cs | Removes obsolete tests for TokenRequest and TokenPollingSettings |
| OAuthFlowTests.cs | Updates test to expect ConsentRequiredException instead of null result |
| UserAuthenticationFeatureTests.cs | Adds new test for token exchange deduplication |
| WriteResult.cs | Adds new class to represent write operation results with ETag |
| ItemExistsException.cs | Adds new exception for duplicate item creation attempts |
| IStorage.cs | Adds StorageWriteOptions record and IStorageExt interface for conditional writes |
| EtagException.cs | Adds XML documentation to existing exception class |
| MemoryStorage.cs | Implements IStorageExt with IfNotExists support and improved error messages |
| CosmosDbPartitionedStorage.cs | Implements IStorageExt with CreateItemAsync for conditional writes |
| BlobsStorage.cs | Implements IStorageExt with IfNoneMatch condition for conditional writes |
| TokenRequest.cs | Marks class as obsolete |
| TokenPollingSettings.cs | Marks class as obsolete |
| UserAuthorizationModuleLoader.cs | Adds ILogger parameter to constructor signature |
| UserAuthorizationDispatcher.cs | Adds CancelledException handling and passes logger to constructors |
| UserCancelledException.cs | Changes base class to CancelledException |
| OAuthFlow.cs | Throws ConsentRequiredException instead of sending response inline |
| ConsentRequiredException.cs | Adds new exception for consent-required scenarios |
| CancelledException.cs | Adds new base exception for cancelled operations |
| Deduplicate.cs | Major refactor to use storage-based deduplication with user-based keys |
| AzureBotUserAuthorization.cs | Consolidates authentication flow logic and adds Category tracking |
| AgentUserAuthorization.cs | Removed (logic moved to AzureBotUserAuthorization) |
| IUserAuthorizationFlow.cs | Removed (interface no longer needed) |
| SignInStatus.cs | Adds Cancelled enum value with documentation |
| UserAuthorization.cs | Improves state management timing and adds Cancelled status handling |
| AgentApplication.cs | Minor formatting fixes |
| OAuthPrompt.cs | Adds ConsentRequiredException catch block |
| AuthAgent.cs | Removes verification code for token comparison |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
This PR adds the new deduplication logic to supported storages (blobs, memory, and cosmos), improves the authorization classes, and fixes a few authorization issues.
Testing
The following images show the deduplication check working, and a fix for the consent leaving on an unwanted state.

