azure-activedirectory-identitymodel-extensions-for-dotnet: BUG : System.IdentityModel.Tokens.Jwt 6.12.1 causes exceptions
I have several API projects where this package was installed. I recently updated to 6.12.1 from 6.12.0 through nuget and started getting exceptions.
System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'System.String'.
---> System.MissingMethodException: Method not found: 'Void Microsoft.IdentityModel.Logging.IdentityModelTelemetryUtil.SetTelemetryData(System.Net.Http.HttpRequestMessage)'.
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel)
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel)
at Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever.GetAsync(String address, IDocumentRetriever retriever, CancellationToken cancel)
at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel)
--- End of inner exception stack trace ---
at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel)
at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync()
at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme)
at Microsoft.AspNetCore.Authorization.Policy.PolicyEvaluator.AuthenticateAsync(AuthorizationPolicy policy, HttpContext context)
at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Serilog.AspNetCore.RequestLoggingMiddleware.Invoke(HttpContext httpContext)
Oddly, I found that I actually no longer need this package at all, and have removed it, thus solving my issue. But I’m wondering if 6.12.1 has some dependency problem when installed.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 34 (16 by maintainers)
Confirmed. If I take another explicit dependency on
the exception is resolved.
In my case, it may have been related to a cached instance of our repository manager on my local machine. Once the bad package was removed from nuget and I invalidated my cache, builds succeeded again.
My repro was to reference a dependency which referenced this package. Beyond that I can’t say unfortunately.
On Fri, Aug 13, 2021 at 6:13 PM henrikm @.***> wrote:
@jennyf19 Yes it does.
Upgrading to version
1.16.0
ofMicrosoft.Identity.Web
and removing the direct reference toMicrosoft.IdentityModel.Protocols
makes everything work as before.Thank you 😃
@stap123 can you try with Microsoft.Identity.Web version 1.16.0, which references Microsoft.IdentityModel.* as 6.*, so hopefully that works for you without a direct reference.
Can confirm the issue, I had to wrestle with the problem for the whole day until I found the culprit. Microsoft.IdentityModel.Tokens works with version 6.12.0, but 6.12.1 causes exceptions breaking the app.
I have entirely deleted the package reference from the project and it’s back working fine.
Now I understand. From Microsoft.IdentityModel.Logging
And my Protocols version is 6.12.0 from the Microsoft.Identity.Web dependency. And so the signatures don’t match.
So really, this is a potential problem for the wider world. Consider two unrelated packages, and the maintainers are dead. One takes a dependency on Protocols 6.12.0, and one takes a dependency on Tokens.Jwt 6.12.1. You’d have to fix it by taking an explicit dependency on Protocols 6.12.1, and hope that Protocols doesn’t have breaking changes for your other dependency.
Wouldn’t it be safer to maintain backwards compatibility and provide both method signatures?
Seems like you found it. Now that you relisted the package, I recreated my issue. I confirmed that after building, I only have version 6.12.1 of Tokens.Jwt.dll in my solution output. So the method sig change error makes sense.
Seems like this kind of a change is really dangerous no? It will break anything that has a dependency on this package and uses that method.
I removed or downgraded to 6.12.0 this package only , System.IdentityModel.Tokens.Jwt, in the Infrastructure project.
references IdentityModel, current latest release references 6.12.0
Can confirm the issue is resolved once Nexus cache was cleared. Not sure what went wrong with the package itself though. Good luck
On Fri, Aug 13, 2021, 6:20 PM henrikm @.***> wrote: