Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.MissingMethodException: Method not found #96

Open
moxixuan opened this issue May 3, 2024 · 1 comment
Open

System.MissingMethodException: Method not found #96

moxixuan opened this issue May 3, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@moxixuan
Copy link

moxixuan commented May 3, 2024

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:
eyJhbGciOiJSUzI1NiIsImtpZCI6ImNlcnQtYnVpbHQtaW4iLCJ0eXAiOiJKV1QifQ.eyJvd25lciI6InR0cy1saXZlIiwibmFtZSI6InR0cy1saXZlLXRlc3R1c2VyIiwiY3JlYXRlZFRpbWUiOiIyMDI0LTA1LTAyVDA5OjM4OjU3KzA4OjAwIiwidXBkYXRlZFRpbWUiOiIyMDI0LTA1LTAyVDAxOjQwOjExWiIsImRlbGV0ZWRUaW1lIjoiIiwiaWQiOiIxMjAyZmI3Ny05Yzk4LTRhZWMtYmQyOC00NmFiZGNhOWU5YjgiLCJ0eXBlIjoibm9ybWFsLXVzZXIiLCJwYXNzd29yZCI6IiIsInBhc3N3b3JkU2FsdCI6IiIsInBhc3N3b3JkVHlwZSI6InBsYWluIiwiZGlzcGxheU5hbWUiOiJ0dHMtbGl2ZS10ZXN0dXNlciIsImZpcnN0TmFtZSI6IiIsImxhc3ROYW1lIjoiIiwiYXZhdGFyIjoiaHR0cHM6Ly9jZG4uY2FzYmluLm9yZy9pbWcvY2FzYmluLnN2ZyIsImF2YXRhclR5cGUiOiIiLCJwZXJtYW5lbnRBdmF0YXIiOiIiLCJlbWFpbCI6InFqNDVkakBleGFtcGxlLmNvbSIsImVtYWlsVmVyaWZpZWQiOmZhbHNlLCJwaG9uZSI6IjU4NjY0ODYxMjUzIiwiY291bnRyeUNvZGUiOiJVUyIsInJlZ2lvbiI6IiIsImxvY2F0aW9uIjoiIiwiYWRkcmVzcyI6W10sImFmZmlsaWF0aW9uIjoiRXhhbXBsZSBJbmMuIiwidGl0bGUiOiIiLCJpZENhcmRUeXBlIjoiIiwiaWRDYXJkIjoiIiwiaG9tZXBhZ2UiOiIiLCJiaW8iOiIiLCJsYW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c3LTljOTgtNGFlYy1iZDI4LTQ2YWJkY2E5ZTliOCIsImF1ZCI6WyJjMzhhNTQyYjQyMTYwMWJhMzg2ZiJdLCJleHAiOjE3MTUzMDM4ODAsIm5iZiI6MTcxNDY5OTA4MCwiaWF0IjoxNzE0Njk5MDgwLCJqdGkiOiJhZG1pbi85NTk1YzVjOS0xNjZlLTQxOGYtOGQ2Ny02MjUyOTI2OTE1NDkifQ.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
AzureAD/azure-activedirectory-identitymodel-extensions-for-dotnet#2059

@casbin-bot
Copy link

@casbin-bot casbin-bot added the question Further information is requested label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants