Skip to content

Conversation

@sw-joelmut
Copy link
Collaborator

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.
image
image

@sw-joelmut sw-joelmut requested a review from a team as a code owner November 12, 2025 17:43
Copilot AI review requested due to automatic review settings November 12, 2025 17:43
@github-actions github-actions bot added ML: Samples Tags changes to samples ML: Core Tags changes to core libraries ML: Tests Tags changes to tests labels Nov 12, 2025
Copy link
Contributor

Copilot AI left a 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 IStorageExt interface 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ML: Core Tags changes to core libraries ML: Samples Tags changes to samples ML: Tests Tags changes to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants