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 perf issue CallDownstreamApi #2355

Closed
jennyf19 opened this issue Jul 29, 2023 · 1 comment
Closed

fix perf issue CallDownstreamApi #2355

jennyf19 opened this issue Jul 29, 2023 · 1 comment
Assignees
Milestone

Comments

@jennyf19
Copy link
Collaborator

Microsoft.Identity.Web Library

Microsoft.Identity.Web

Microsoft.Identity.Web version

2.11.1

Web app

Sign-in users and call web APIs

Web API

Protected web APIs (validating tokens)

Token cache serialization

Not Applicable

Description

The line deleted in MicrosoftIdentityWebApiAuthenticationBuilderExtensions.cs calls builder.Services.Configure which is also happening in the builder constructor itself (MicrosoftIdentityWebApiAuthenticationBuilder) with the same arguments which duplicated the configuration every time a builder was run using the CallDownstreamApi.

Testing:

Unit tests all pass
Succeeded running the DaemonConsoleCallingDownstreamApi sample against the MinimalWebApi sample.
Fixes #{bug number} (in this specific format)

The private function AddMicrosoftIdentityWebApiImplementation I deleted the builder.Services.Configure call from is only called by the two implementations of the AddMicrosoftIdentityWebApi method in the same file (1, 2). These two functions return a new builder, using the same builder Object, JwtBearerOptions, and MicrosoftIdentityOptions used as arguments in the call from private function whose line I deleted. Those two returned builder objects either are or derive from the MicrosoftIdentityWebApiAuthenticationBuilder where on line 45 in the constructor a Services.Configure call is made using those same JwtBearerOptions and MicrosoftIdentityOptions arguments.

Reproduction steps

If you run the dev app which is webAppCallsWebApiCallsGraph, and add this to the service:

services.Configure( o => o.ClientSecret = "your_secret-here");

and comment it out in the appsettings.json then run them both as startup projects. I get this error:

An unhandled exception occurred while processing the request.

HttpRequestException: 500 InternalServerError MSAL.NetCore.4.55.0.0.MsalServiceException:
ErrorCode: invalid_client
Microsoft.Identity.Client.MsalServiceException: A configuration issue is preventing authentication - check the error message from the server for details. You can modify the configuration in the application registration portal. See https://aka.ms/msal-net-invalid-client for details. Original exception: AADSTS7000215: Invalid client secret provided. Ensure the secret being sent in the request is the client secret value, not the client secret ID, for a secret added to app 'a4c2469b-cf84-4145-8f5f-cb7bacf814bc'.

As it's not longer picking up the MicrosoftIdentityOptions.

Error message

No response

Id Web logs

No response

Relevant code snippets

n/a

Regression

No response

Expected behavior

no additional allocations where they are not needed.

@jennyf19
Copy link
Collaborator Author

Included in 2.13.2 release

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

No branches or pull requests

2 participants