Dotnet Core身份验证CorrelationFailed

问题描述 投票:4回答:2

我正在尝试在全新的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;


            });
    }

我出于安全原因修改了一些值,并且我排除了事件,因为我认为这是无关紧要的。

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

如果此文件上的最后一个方法返回false,则会出现“Correlation Failed”错误。

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

任何线索?

authentication .net-core openid-connect identityserver3
2个回答
0
投票

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

    options.CallbackPath = new PathString("/");

0
投票

我有这个问题,这是由RouteOptions中设置的以下选项引起的:

options.LowercaseQueryStrings = true;

这导致在执行重定向回应用程序时state查询参数更低。由于状态区分大小写,因此导致state property not found错误。

© www.soinside.com 2019 - 2024. All rights reserved.