azure-activedirectory-identitymodel-extensions-for-dotnet: [Bug] When using AddJwtBearer it can not read .well-known/openid-configuration if it contains an object
Which version of Microsoft.IdentityModel are you using? Note that to get help, you need to run the latest version.
.net 8.0
Where is the issue?
- M.IM.JsonWebTokens
- M.IM.KeyVaultExtensions
- M.IM.Logging
- M.IM.ManagedKeyVaultSecurityKey
- M.IM.Protocols
- M.IM.Protocols.OpenIdConnect
- M.IM.Protocols.SignedHttpRequest
- M.IM.Protocols.WsFederation
- M.IM.TestExtensions
- M.IM.Tokens
- M.IM.Tokens.Saml
- M.IM.Validators
- M.IM.Xml
- S.IM.Tokens.Jwt
- Other (please describe)
Is this a new or an existing app? New for .net 8.0
Repro
// Minimal api with below config
builder.Services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, options =>
{
options.Authority = "your-idp-here";
options.TokenValidationParameters.ValidateAudience = false;
options.Events = new JwtBearerEvents
{
OnAuthenticationFailed = context =>
{
return Task.CompletedTask;
},
OnTokenValidated = context =>
{
return Task.CompletedTask;
}
};
});
Expected behavior Be able to read .well-known/openid-configuration with object that does not affect OIDC config
Actual behavior Ends reading config on the first }. This stops the read of the rest of the config and in our case ignored the jwks endpoint setting.
Possible solution Ignore unknown objects with a while read loop
Additional context / logs / screenshots / links to code
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 17 (6 by maintainers)
@tehho Yep, you called it. We get away with arrays as the exist condition is JsonTokenType.EndObject, JsonTokenType.EndArray is just gobbled up.
With Objects, we bail early.
Nice Demo code 😃
Will get this fixed.
Note to others coming here: It’s only necessary to include
Microsoft.IdentityModel.Protocols.OpenIdConnect(7.5.2 or later), notMicrosoft.AspNetCore.Authentication.OpenIdConnect.It would be great if MS would update
Microsoft.AspNetCore.Authentication.JwtBearerto depend on the updated version!@bgirts @ClassyCircuit @tehho @unger @brockallen this has been fixed in this PR. Hope to have a release out soon.