-
Notifications
You must be signed in to change notification settings - Fork 129
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
BearerTokenAuthenticationPolicy
to use shared_lock in case no refresh is needed
#5188
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.
My only concern is the 1970 year bias when creating the Azure::DateTime object, otherwise it looks fine.
sdk/core/azure-core/src/http/bearer_token_authentication_policy.cpp
Outdated
Show resolved
Hide resolved
bool TokenNeedsRefresh( | ||
Azure::Core::Credentials::AccessToken const& cachedToken, | ||
Azure::Core::Credentials::TokenRequestContext const& cachedTokenRequestContext, | ||
Azure::DateTime const& currentTime, | ||
Azure::Core::Credentials::TokenRequestContext const& newTokenRequestContext) | ||
{ | ||
return newTokenRequestContext.TenantId != cachedTokenRequestContext.TenantId | ||
|| newTokenRequestContext.Scopes != cachedTokenRequestContext.Scopes | ||
|| currentTime > (cachedToken.ExpiresOn - newTokenRequestContext.MinimumExpiration); | ||
} |
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.
This logic could benefit from a comment. For example, I understand that we need a token refresh if the tenant id and scope don't match, but why are we using current token's and cached token's expirations together like this: cachedToken.ExpiresOn - newTokenRequestContext.MinimumExpiration
?
Closes #4756.
--
UWP CI is currently blocked until microsoft/vcpkg#35279 is fixed / microsoft/vcpkg#35116 is merged (#5181 would unblock)