Skip to content

JwtBearerOptions.Authority must be explicitly set to null on Windows 11 #64841

@dan-p-dev

Description

@dan-p-dev

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When configuring the JwtBearerOptions in AddJwtBearer, the JwtBearerOptions.Authority member needs to be explicitly set to null on Windows 11. If it is not, the authentication middleware will try to search for an OpenID Connect server that doesn't exist, and lag for a few seconds before continuing.

Expected Behavior

The authentication middleware should not attempt to query an OpenID Connect server without explicitly being configured to do so.

Steps To Reproduce

Clone example repository: https://github.com/dan-p-dev/JwtError
In my tests, I've been creating a token with dotnet user-jwts create, and curl to GET from the test endpoint. The request will lag for a few seconds before completing successfully.

I used dotnet-trace to profile the request, and a function call for OpenIdConnect.OpenIdConnectConfigurationRetriever+<GetAsync>d__3::Move appears in the results.

After testing this, I uncommented line line 26 in Program.cs (jwtOptions.Authority = null;) and repeated my tests. In this case, there is no lag in the request, and dotnet-trace shows no OpenIdConnect related function calls.

Exceptions (if any)

This error does not occur on any of the Linux-based systems I tested on, despite occurring on each Windows 11 system. All systems had the same dotnet version.

.NET Version

10.0.101

Anything else?

Windows Version: Windows 11 Pro
OS Version: 10.0.26200

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-authIncludes: Authn, Authz, OAuth, OIDC, Bearer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions