dotnet / dotnet/sdk

OpenID Metadata not getting cached

Open
#53,049 0 comments 0 reactions 0 assignees View on GitHub
untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

After upgrading my .net 8 Project to .net 9 or .net 10 I have issues with OpenID Metadata not getting cached when validating an Entra Token.
Each request the OpenID data get fetched again.

Performance **before uprading**:

Image

**After upgrading** to newer .net including new Authentication.JWTBearer Package
Image

**Before Upgrade:**

Request to /usageTypes took 139ms.
Breakdown: PreAuth: 0,05ms,
Validation: 0,16ms,
Endpoint: 139,38ms.

**After Upgrade**
Request to /usageTypes took 456ms.
Breakdown: PreAuth: 30,96ms,
Validation: 248,30ms,
Endpoint: 176,93ms

My program.cs configuration is very basic. Nothing special:

Image

I can fix it by either downgrading to .net 8 or precaching the configManager:

Image

The endpoint is also very simple

Image

### To Reproduce
In my case, just use any entra configuration with

`builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddMicrosoftIdentityWebApi(builder.Configuration.GetSection("AzureAd"));`

I tested it on different devices (same issue).

` "AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "xxxxxx",
"ClientId": "yyyyy",
"CallbackPath": "/signin-oidc"
},`

### Further technical details
details of dotnet --info


.NET SDKs installed:
9.0.306 [C:\Program Files\dotnet\sdk]
10.0.102 [C:\Program Files\dotnet\sdk]
10.0.103 [C:\Program Files\dotnet\sdk]

- Rider, Windows 11.
My csproj:

Image

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.