-
Notifications
You must be signed in to change notification settings - Fork 278
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
Fix | Fix driver to not send expired token and refresh token first before sending it. #2273
Fix | Fix driver to not send expired token and refresh token first before sending it. #2273
Conversation
…e executed directly inside a function with [ConditionalFact] annotation.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2273 +/- ##
==========================================
- Coverage 72.58% 72.31% -0.28%
==========================================
Files 309 310 +1
Lines 61959 61877 -82
==========================================
- Hits 44976 44746 -230
- Misses 16983 17131 +148
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
...ata.SqlClient/tests/ManualTests/SQL/AADFedAuthTokenRefreshTest/AADFedAuthTokenRefreshTest.cs
Outdated
Show resolved
Hide resolved
...ata.SqlClient/tests/ManualTests/SQL/AADFedAuthTokenRefreshTest/AADFedAuthTokenRefreshTest.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.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.
As a general question that can be addressed here or in a separate PR: If a token needs to be included in the AuthenticationContexts
with active pooling, why not encapsulate all the logic, including calls to the GetFedAuthToken
method, within a dedicated function?
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Outdated
Show resolved
Hide resolved
...crosoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj
Outdated
Show resolved
Hide resolved
...crosoft.Data.SqlClient/tests/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj
Show resolved
Hide resolved
...ata.SqlClient/tests/ManualTests/SQL/AADFedAuthTokenRefreshTest/AADFedAuthTokenRefreshTest.cs
Outdated
Show resolved
Hide resolved
...ata.SqlClient/tests/ManualTests/SQL/AADFedAuthTokenRefreshTest/AADFedAuthTokenRefreshTest.cs
Outdated
Show resolved
Hide resolved
...ata.SqlClient/tests/ManualTests/SQL/AADFedAuthTokenRefreshTest/AADFedAuthTokenRefreshTest.cs
Outdated
Show resolved
Hide resolved
…cation Helper using reflection. Also, applied SOLID and DRY principles.
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.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.
Let's go clean code here.
src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/SqlInternalConnectionTds.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.
If we had time I would ask for improving the helper method, which is not a blocker for now.
Also, your PR shows irrelevant changes, which shouldn't be as part of your PR! It can be related to the way you merge and push.
This PR fixes issue #2238.
The SqlClient driver is supposed to be refreshing AuthFedTokens within 10 minutes before they expire so that they do not get sent to the server in a expired state. However, the cache, _dbConnectionPool.AuthenticationContexts, of AuthFedTokens to be refreshed was always empty because newly created AuthFedTokens are not getting added to it. Thus, no AuthFedTokens are getting refreshed.
This fix ensures that all newly created AuthFedTokens are added to the cache, _dbConnectionPool.AuthenticationContexts, and thereby gets refreshed within 10 minutes of them expiring. This ensures that no AuthFedTokens gets sent to the server in a expired state.