casdoor / casdoor-dotnet-sdk

.NET client SDK for Casdoor
https://github.com/casdoor/casdoor
Apache License 2.0
28 stars 25 forks source link

System.MissingMethodException: Method not found #96

Open moxixuan opened 6 months ago

moxixuan commented 6 months ago

when Casdoor.AspNetCore nuget <= 1.12.0 it's ok. but when Casdoor.AspNetCore nuget > 1.12.0 it return 401

[09:20:31 INF] ├ HTTP GET http://203.195.158.109:8001/.well-known/openid-configuration (26.73 ms) [09:20:31 INF] ├ HTTP GET http://203.195.158.109:8001/.well-known/openid-configuration (23.007 ms) [09:20:31 INF] ├ HTTP GET http://203.195.158.109:8001/.well-known/jwks (13.951 ms) [09:20:31 INF] ├ HTTP GET http://203.195.158.109:8001/.well-known/jwks (39.214 ms) [09:20:31 INF] │ Failed to validate the token. System.MissingMethodException: Method not found: 'Boolean Microsoft.IdentityModel.Tokens.TokenUtilities.IsRecoverableConfiguration(Microsoft.IdentityModel.Tokens.TokenValidationParameters, Microsoft.IdentityModel.Tokens.BaseConfiguration, Microsoft.IdentityModel.Tokens.BaseConfiguration ByRef)'. at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, JwtSecurityToken outerToken, TokenValidationParameters validationParameters, SecurityToken& signatureValidatedToken) at System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler.ValidateToken(String token, TokenValidationParameters validationParameters, SecurityToken& validatedToken) at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() [09:20:31 INF] │ Bearer was not authenticated. Failure message: Method not found: 'Boolean Microsoft.IdentityModel.Tokens.TokenUtilities.IsRecoverableConfiguration(Microsoft.IdentityModel.Tokens.TokenValidationParameters, Microsoft.IdentityModel.Tokens.BaseConfiguration, Microsoft.IdentityModel.Tokens.BaseConfiguration ByRef)'. [09:20:31 INF] │ Authorization failed. These requirements were not met: DenyAnonymousAuthorizationRequirement: Requires an authenticated user. [09:20:31 INF] │ AuthenticationScheme: Bearer was challenged.

here is token: eyJhbGciOiJS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DgwLCJqdGkiOiJhZG1pbi85NTk1YzVjOS0xNjZlLTQxOGYtOGQ2Ny02MjUyOTI2OTE1NDkifQ.d30s4gBBRI7jMOGxZihEFUxWOczx9IjgIwKmF9HHpSSeiidK2LZP2tmFnoNwKBgESrEnCtBabv0QcrSDpXnVdoiSpomp0k65TdlGt1cd-ms1UlllqizRGTxxCjdkl8YnSGxu3nIdAbyAOX7nIbytYu7Sczj0r3ftVai7EOKWVfCAKJRsDm6IK4q2lQPmJeVzreF9K_2MC4yk5QXwfFP-kpLkE9tzKS_JsJf16ksI8rJI1r2qnqWIqPwoLJkm9yg7Mpmmdf3ICs0xdmlSpNC4k3UvPuKNBYWcrrzLqtz2MPNo5YxJNhKaAKRah4yXq6BP1sJbtnc5EKMA9Fq2KGtLUpX8_ovXoiWocNHMJFBdfmHE91IB4-404K6-U4SLIFkS4_QAJSvjKphfY3ouk8CMzdLH4C_KM8ikcmP8iVeTc4cXtw4GeI1wXDMk4l_VnWgAKZ_MFewxAu22eAnqrA5WW9L1jT-7hzR_0aAN_1UWLegXr04LyLpzq8Y_c-5Lb2JhRHabUd3F80VsHVevOG5SSw8f5qoDsNahAeho9hs0AdLwD2F17gBeKuLCWLFq_DedwQ1KpqkGXYrB44pl_zRcag5doXWh_oKxfWoXcCeuCnxKtUnQ_5U7Km_b7EFXzKVEvYzpDZDYO-IJnugBZK7IHrB4JoZMxmbniEjEexCcGVo

here is my code

    builder.Services
        .AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
        .AddCasdoorWebApi(options =>
        {
            options.RequireHttpsMetadata = false;
            IdentityModelEventSource.ShowPII = true;
           options.TokenValidationParameters = new TokenValidationParameters()
            {
                ValidAudiences = new[]
                {
                    builder.Configuration[$"{nameof(CasdoorOptions)}:ClientId"],
                }
            };
        });
    builder.Services.AddAuthorization();

here is some about https://github.com/AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet/issues/2059

casbin-bot commented 6 months ago

@tangyang9464 @JalinWang @imp2002