-
Notifications
You must be signed in to change notification settings - Fork 345
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
Add token source enum #1933
Add token source enum #1933
Conversation
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.
Where are you setting the broker token source enum?
src/client/Microsoft.Identity.Client/AuthenticationResultMetadata.cs
Outdated
Show resolved
Hide resolved
src/client/Microsoft.Identity.Client/Microsoft.Identity.Client.csproj
Outdated
Show resolved
Hide resolved
...icrosoft.Identity.Test.Integration.net45/HeadlessTests/ConfidentialClientIntegrationTests.cs
Outdated
Show resolved
Hide resolved
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.
Looks good, only small issue is to remove the changes to the csproj file. I think you need to add the changes needed for the broker before committing - see the IBroker interface.
/// The source of the access and Id token is Identity Provider - Azure Active Directory (AAD), ADFS or AAD B2C. | ||
/// </summary> | ||
IdentityProvider, | ||
/// <summary> |
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.
nit: would you want to separate b2c from AAD and ADFS or does it matter? Should it be called AuthorizationServer
? When i think of an Identity provider, I think of Google or FB or Microsoft...really just a question
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.
The goal of this small improvement is for developers, especially on Identity.Web, to monitor their token cache hit ratio. There are other proposals around providing more details such as "which broker (name and version) was used?", but will treat them separately.
Not sure about the naming, I proposed the OAuth2 term. @jmprieur - what do you think?
@@ -155,6 +155,7 @@ public async Task SilentAuth_TokenCacheRemainsPersistent_Async() | |||
Assert.IsFalse(at1.Equals(at2, System.StringComparison.InvariantCultureIgnoreCase)); | |||
Assert.IsFalse(at1.Equals(at3, System.StringComparison.InvariantCultureIgnoreCase)); | |||
Assert.IsFalse(at2.Equals(at3, System.StringComparison.InvariantCultureIgnoreCase)); | |||
Assert.AreEqual(TokenSource.IdentityProvider, authResult.AuthenticationResultMetadata.TokenSource); | |||
} |
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.
can you assert earlier, like after line 133, that the TokenSource is TokenSource.Cache
...I guess finding one that does AT silent and pulls from the cache. I would just add this check in all the tests, what about the interactive tests and broker tests?
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.
Or after line 145, that AcquireTokenSilent gets a token from teh cache.
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.
@bgavrilMS That one is withForceRefresh(True) so it would not get the token from the cache. Right?
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.
Added in the other method where force refresh was false.
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.
the assertion at line 158 is correct - force_refresh means "do not look for an AT in the cache".
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.
src/client/Microsoft.Identity.Client/Internal/Requests/RequestBase.cs
Outdated
Show resolved
Hide resolved
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.
We should not expose TokenSource.None and we need a unit test or two aroun broker.
If the access token expires the refresh token is used to refresh the token and acquire a new access token. Thus, the token is actually coming from AAD in this case. are you accounting for this scenario somewhere? Edit: NVM, found it #Resolved Refers to: src/client/Microsoft.Identity.Client/Internal/Requests/Silent/SilentClientAuthStrategy.cs:119 in 0e4447b. [](commit_id = 0e4447b, deletion_comment = False) |
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.
I agree with all of the previous comments and it looks like you covered all of the broker scenarios.
LGTM
#1728