Skip to content

Use per-config refresh context for OAuth tokens#728

Merged
nfx merged 2 commits intomainfrom
fix/refresh-ctx
Dec 4, 2023
Merged

Use per-config refresh context for OAuth tokens#728
nfx merged 2 commits intomainfrom
fix/refresh-ctx

Conversation

@nfx
Copy link
Copy Markdown
Contributor

@nfx nfx commented Dec 4, 2023

Changes

This PR uses per-config refresh context for all oauth2 tokens, so that it's separate from the context coming in the first request (as before)

Tests

  • make test passing
  • make fmt applied
  • azure env
  • gcp env

This PR uses per-conflig refresh context for all oauth2 tokens, so that it's separate from the context coming in the first request (as before)
@nfx nfx requested a review from mgyucht December 4, 2023 11:44
Copy link
Copy Markdown
Contributor

@pietern pietern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it need to be separate?

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (964cdc1) 17.58% compared to head (f514b9a) 17.62%.

Files Patch % Lines
config/auth_azure_client_secret.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #728      +/-   ##
==========================================
+ Coverage   17.58%   17.62%   +0.04%     
==========================================
  Files         103      103              
  Lines       14191    14197       +6     
==========================================
+ Hits         2495     2502       +7     
+ Misses      11491    11490       -1     
  Partials      205      205              

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

@nfx nfx enabled auto-merge December 4, 2023 13:07
@mgyucht
Copy link
Copy Markdown
Contributor

mgyucht commented Dec 4, 2023

@pietern because request contexts can have a timeout, but Go's OAuth2 lib caches the context used to create the token source, so we need to be very sure to use a separate context without a timeout.

@nfx nfx added this pull request to the merge queue Dec 4, 2023
Comment on lines +41 to +42
StatusCode: statusCode,
Status: status,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @hectorcast-db who was going to fix this.

Merged via the queue into main with commit 2dbf06a Dec 4, 2023
@nfx nfx deleted the fix/refresh-ctx branch December 4, 2023 16:49
mgyucht added a commit that referenced this pull request Dec 7, 2023
This is a bugfix release, including a fix correcting issues with OAuth flows, due to a bug with the propagation of the response status in `httpclient`'s `RoundTrip()` implementation. This fixes the `failed during request visitor: token: oauth2: cannot fetch token: Response: {...}` error.

All fixes:

* Migrate Azure MSI & Metadata Service token sources to `httpclient` and add 100% test coverage ([#709](#709)).
* Added `config.NewAzureCliTokenSource` and `config.NewAzureMsiTokenSource` constructors ([#727](#727)).
* Use per-config refresh context for OAuth tokens ([#728](#728)).
@mgyucht mgyucht mentioned this pull request Dec 7, 2023
github-merge-queue bot pushed a commit that referenced this pull request Dec 7, 2023
This is a bugfix release, including a fix correcting issues with OAuth
flows, due to a bug with the propagation of the response status in
`httpclient`'s `RoundTrip()` implementation. This fixes the `failed
during request visitor: token: oauth2: cannot fetch token: Response:
{...}` error.

All fixes:

* Migrate Azure MSI & Metadata Service token sources to `httpclient` and
add 100% test coverage
([#709](#709)).
* Added `config.NewAzureCliTokenSource` and
`config.NewAzureMsiTokenSource` constructors
([#727](#727)).
* Use per-config refresh context for OAuth tokens
([#728](#728)).
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.

4 participants