Skip to content
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

Merged
merged 15 commits into from
Jan 24, 2024

Conversation

arellegue
Copy link
Contributor

@arellegue arellegue commented Dec 17, 2023

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.

Copy link

codecov bot commented Dec 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4203237) 72.58% compared to head (fa913b1) 72.31%.
Report is 30 commits behind head on main.

❗ Current head fa913b1 differs from pull request most recent head 0950949. Consider uploading reports for the commit 0950949 to get more accurate results

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     
Flag Coverage Δ
addons 92.88% <ø> (ø)
netcore 76.18% <100.00%> (-0.65%) ⬇️
netfx 70.07% <100.00%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@DavoudEshtehari DavoudEshtehari left a 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?

@H-Yeo H-Yeo modified the milestones: 5.2.0-preview5, 5.2.0 Jan 24, 2024
Copy link
Contributor

@H-Yeo H-Yeo left a 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.

Copy link
Member

@DavoudEshtehari DavoudEshtehari left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Driver sending expired token intermittently during Azure login
5 participants