-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[csharp][generichost] Multiple oauth tokens #23264
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -847,14 +847,20 @@ public async Task<IAddPetApiResponse> AddPetAsync(Pet pet, System.Threading.Canc | |
|
|
||
| oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); | ||
|
|
||
| HttpSignatureToken httpSignatureTokenLocalVar2 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); | ||
| OAuthToken oauthTokenLocalVar2 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: AddPetAsync requests two OAuth tokens from the same provider with no discriminator and applies both to the Authorization header, so the second UseInHeader call overwrites the first. The client still cannot send two distinct OAuth credentials for two schemes. Prompt for AI agents |
||
|
|
||
| tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); | ||
| tokenBaseLocalVars.Add(oauthTokenLocalVar2); | ||
|
|
||
| oauthTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, ""); | ||
|
|
||
| HttpSignatureToken httpSignatureTokenLocalVar3 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); | ||
|
|
||
| tokenBaseLocalVars.Add(httpSignatureTokenLocalVar3); | ||
|
|
||
| if (httpRequestMessageLocalVar.Content != null) { | ||
| string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); | ||
|
|
||
| httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); | ||
| httpSignatureTokenLocalVar3.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); | ||
| } | ||
|
|
||
| string[] contentTypes = new string[] { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,6 +76,9 @@ public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaul | |
| string oauthTokenValue1 = context.Configuration["<token>"] ?? throw new Exception("Token not found."); | ||
| OAuthToken oauthToken1 = new(oauthTokenValue1, timeout: TimeSpan.FromSeconds(1)); | ||
| options.AddTokens(oauthToken1); | ||
| string oauthTokenValue2 = context.Configuration["<token>"] ?? throw new Exception("Token not found."); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Both OAuth tokens are built from the same configuration key and OAuthToken has no scheme identifier, so multiple OAuth schemes cannot be distinguished and share one token value. Prompt for AI agents |
||
| OAuthToken oauthToken2 = new(oauthTokenValue2, timeout: TimeSpan.FromSeconds(1)); | ||
| options.AddTokens(oauthToken2); | ||
| }); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -849,14 +849,20 @@ public async Task<IAddPetApiResponse> AddPetAsync(Pet pet, System.Threading.Canc | |
|
|
||
| oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); | ||
|
|
||
| HttpSignatureToken httpSignatureTokenLocalVar2 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); | ||
| OAuthToken oauthTokenLocalVar2 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); | ||
|
|
||
| tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); | ||
| tokenBaseLocalVars.Add(oauthTokenLocalVar2); | ||
|
|
||
| oauthTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, ""); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Second OAuth token overwrites the first because both calls use Authorization without a scheme identifier, so multiple OAuth credentials aren’t actually sent. Prompt for AI agents |
||
|
|
||
| HttpSignatureToken httpSignatureTokenLocalVar3 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); | ||
|
|
||
| tokenBaseLocalVars.Add(httpSignatureTokenLocalVar3); | ||
|
|
||
| if (httpRequestMessageLocalVar.Content != null) { | ||
| string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); | ||
|
|
||
| httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); | ||
| httpSignatureTokenLocalVar3.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); | ||
| } | ||
|
|
||
| string[] contentTypes = new string[] { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -847,14 +847,20 @@ public async Task<IAddPetApiResponse> AddPetAsync(Pet pet, System.Threading.Canc | |
|
|
||
| oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); | ||
|
|
||
| HttpSignatureToken httpSignatureTokenLocalVar2 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); | ||
| OAuthToken oauthTokenLocalVar2 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Second OAuth token overwrites the first because UseInHeader always sets the Authorization header; two OAuth requirements cannot both be sent. Prompt for AI agents |
||
|
|
||
| tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); | ||
| tokenBaseLocalVars.Add(oauthTokenLocalVar2); | ||
|
|
||
| oauthTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, ""); | ||
|
|
||
| HttpSignatureToken httpSignatureTokenLocalVar3 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); | ||
|
|
||
| tokenBaseLocalVars.Add(httpSignatureTokenLocalVar3); | ||
|
|
||
| if (httpRequestMessageLocalVar.Content != null) { | ||
| string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); | ||
|
|
||
| httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); | ||
| httpSignatureTokenLocalVar3.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); | ||
| } | ||
|
|
||
| string[] contentTypes = new string[] { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
P2: Second OAuth token registration overwrites the first because AddTokens registers a singleton TokenContainer per token type, so only one OAuthToken is retained and both are loaded from the same config key.
Prompt for AI agents