Dotnet Core 身份验证关联失败

Geo*_*ros 5 authentication openid-connect .net-core identityserver3

我正在尝试在全新的 dotnet 核心应用程序上设置身份验证。我使用的 IdentityServer 工作正常,因为它被用于其他应用程序。

我收到的错误只是“关联失败”。查看 VS2017 中的输出,我在异常之前看到一个警告,内容如下:

Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler:警告:.AspNetCore.Correlation。未找到国家财产。

这是我的配置:

    public void ConfigureServices(IServiceCollection services)
    {
        Debugger.Break();
        services.AddMvc();

        services.AddAuthentication(options =>
            {
                options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
            })
            .AddCookie(options =>
            {
                options.SlidingExpiration = true;
                options.Cookie.Name = "MyAwesomeCookie";
                options.ExpireTimeSpan = TimeSpan.FromMinutes(30);

            })
            .AddOpenIdConnect(options =>
            {
                options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.Authority = IdentityServerConstants.IdentityServerUrl;
                options.ClientId = "myclientid";
                options.ClientSecret = "supersecuresecret";

                //options.CorrelationCookie.Name = "something";

                foreach (var s in myScopes)
                {
                    options.Scope.Add(s);
                }
                options.ResponseType = "code id_token token";
                options.CallbackPath = new PathString("/");

                options.UseTokenLifetime = false;
                options.RequireHttpsMetadata = false;


            });
    }
Run Code Online (Sandbox Code Playgroud)

出于安全原因,我修改了一些值,并排除了事件挂钩,因为我认为它无关紧要。

我可以追踪到这个文件:https : //github.com/aspnet/Security/blob/dev/src/Microsoft.AspNetCore.Authentication/RemoteAuthenticationHandler.cs

如果此文件的最后一个方法返回 false,则您会收到“关联失败”错误。

但是,我花了很长时间在谷歌上搜索错误,但找不到解决方法。我可能在配置中遗漏了一些微不足道的东西......

有什么线索吗?

Mat*_*hew 0

我没有解释为什么会出现这种情况,但我遇到了同样的错误并设法通过删除此行来解决它:

    options.CallbackPath = new PathString("/");
Run Code Online (Sandbox Code Playgroud)