-
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
Open
sw-joelmut
wants to merge
19
commits into
main
Choose a base branch
from
users/tracyboehrer/blobs-dedupe
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
2dc0df6
Dedupe POC
a64e067
Merge branch 'main' into users/tracyboehrer/blobs-dedupe
a86a487
Dedupe uses new IStorage.Write method
cadcfee
Refactored AzureBotUserAuthorization to include AgentUserAuthorizatio…
e1fbc28
Merge branch 'main' into users/tracyboehrer/blobs-dedupe
1b229d3
Merge branch 'main' into users/tracyboehrer/blobs-dedupe
5c2e150
Fix deduplication and added some testing logs to understand why the a…
sw-joelmut 545015c
Disabled OnMe same connection check for testing
a98917c
Add auth reset when user cancels on token exchange consent
sw-joelmut e8c288e
Merge branch 'users/tracyboehrer/blobs-dedupe' of https://github.com/…
sw-joelmut 8b27323
Minor UserAuthorization cleanup/comments.
7280542
Merge remote-tracking branch 'upstream/main' into users/tracyboehrer/…
sw-joelmut 2450afe
cleanup and apply last changes to dedup and consent cancel flow
sw-joelmut 0ecf76f
Fix formatting
sw-joelmut edd8240
Improve code and update unit tests
sw-joelmut 504aa6c
remove wrong comment
sw-joelmut a6b7682
Add docs and remove unnecessary usings
sw-joelmut a873ade
Merge remote-tracking branch 'origin/main' into users/tracyboehrer/bl…
sw-joelmut c9c854c
Merge branch 'main' into users/tracyboehrer/blobs-dedupe
tracyboehrer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,16 +1,16 @@ | ||||||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||||||
| // Licensed under the MIT License. | ||||||
|
|
||||||
| using Microsoft.Agents.Builder.Errors; | ||||||
| using Microsoft.Agents.Builder.State; | ||||||
| using Microsoft.Agents.Builder.UserAuth; | ||||||
| using System.Threading.Tasks; | ||||||
| using System.Threading; | ||||||
| using System; | ||||||
| using Microsoft.Agents.Core.Errors; | ||||||
| using Microsoft.Agents.Core.Models; | ||||||
| using Microsoft.Agents.Core.Serialization; | ||||||
| using Microsoft.Agents.Builder.Errors; | ||||||
| using System; | ||||||
| using System.Collections.Generic; | ||||||
| using Microsoft.Agents.Core.Errors; | ||||||
| using System.Threading; | ||||||
| using System.Threading.Tasks; | ||||||
|
|
||||||
| namespace Microsoft.Agents.Builder.App.UserAuth | ||||||
| { | ||||||
|
|
@@ -105,16 +105,16 @@ public async Task<string> ExchangeTurnTokenAsync(ITurnContext turnContext, strin | |||||
| if (_authTokens.TryGetValue(handlerName, out var token)) | ||||||
| { | ||||||
| // An exchangeable token needs to be exchanged. | ||||||
| if (!turnContext.IsAgenticRequest()) | ||||||
| { | ||||||
| if (!token.IsExchangeable) | ||||||
| { | ||||||
| var diff = token.Expiration - DateTimeOffset.UtcNow; | ||||||
| if (diff.HasValue && diff?.TotalMinutes >= 5) | ||||||
| { | ||||||
| return token.Token; | ||||||
| } | ||||||
| } | ||||||
| if (!turnContext.IsAgenticRequest()) | ||||||
| { | ||||||
| if (!token.IsExchangeable) | ||||||
| { | ||||||
| var diff = token.Expiration - DateTimeOffset.UtcNow; | ||||||
| if (diff.HasValue && diff?.TotalMinutes >= 5) | ||||||
| { | ||||||
| return token.Token; | ||||||
| } | ||||||
| } | ||||||
sw-joelmut marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| } | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -185,14 +185,35 @@ internal async Task<bool> StartOrContinueSignInUserAsync(ITurnContext turnContex | |||||
| // Auth flow hasn't start yet. | ||||||
| activeFlowName ??= handlerName ?? DefaultHandlerName; | ||||||
|
|
||||||
| if (!flowContinuation) | ||||||
| { | ||||||
| // Bank the incoming Activity so it can be executed after sign in is complete. | ||||||
| signInState.ContinuationActivity = turnContext.Activity; | ||||||
| signInState.ActiveHandler = activeFlowName; | ||||||
|
|
||||||
| // Save state now to avoid potential race with overlapping requests. | ||||||
| await turnState.SaveStateAsync(turnContext, cancellationToken: cancellationToken).ConfigureAwait(false); | ||||||
| } | ||||||
|
|
||||||
| // Get token or start flow for specified flow. | ||||||
| SignInResponse response = await _dispatcher.SignUserInAsync( | ||||||
| turnContext, | ||||||
| activeFlowName, | ||||||
| forceSignIn: !flowContinuation, | ||||||
| exchangeConnection: signInState.RuntimeOBOConnectionName, | ||||||
| exchangeScopes: signInState.RuntimeOBOScopes, | ||||||
| cancellationToken: cancellationToken).ConfigureAwait(false); | ||||||
| turnContext, | ||||||
| activeFlowName, | ||||||
| forceSignIn: !flowContinuation, | ||||||
| exchangeConnection: signInState.RuntimeOBOConnectionName, | ||||||
| exchangeScopes: signInState.RuntimeOBOScopes, | ||||||
| cancellationToken: cancellationToken).ConfigureAwait(false); | ||||||
|
|
||||||
| if (response.Status == SignInStatus.Cancelled) | ||||||
| { | ||||||
| // This is only for safety in case of unexpected behaviors during the MS Teams sign-in process, | ||||||
| // e.g., user interrupts the flow by clicking the Consent Cancel button. | ||||||
| DeleteSignInState(turnState); | ||||||
| await _dispatcher.ResetStateAsync(turnContext, activeFlowName, cancellationToken).ConfigureAwait(false); | ||||||
| await turnState.SaveStateAsync(turnContext, cancellationToken: cancellationToken).ConfigureAwait(false); | ||||||
| // Return true since at this point we are in a continuation flow, an we need to start a new flow that is handled later. | ||||||
|
||||||
| // Return true since at this point we are in a continuation flow, an we need to start a new flow that is handled later. | |
| // Return true since at this point we are in a continuation flow, and we need to start a new flow that is handled later. |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.