authentication - Dotnet Core 身份验证关联失败

标签 authentication .net-core openid-connect identityserver3

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

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

Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectHandler:Warning: .AspNetCore.Correlation. state property not found.



这是我的配置:
    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;


            });
    }

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

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

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

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

有什么线索吗?

最佳答案

我没有解释为什么会这样,但我遇到了同样的错误,并通过删除这一行设法解决了它:

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

关于authentication - Dotnet Core 身份验证关联失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48476635/

相关文章:

php - 给出错误消息并提交给自己的登录页面

.net-core - .net core 项目如何在构建时知道要包含哪些文件

c# - 如何在dotnet core中将动态对象序列化为JSON字符串?

c# - [C#、.NET] : Validating users via LDAP through IdentityServer3

authentication - 在运行时向 OWIN 管道注册新的中间件,无需重新启动应用程序

logging - 如何监控成功登录 Jenkins 服务器的用户日志?

authentication - Polymer 1.0 : User authentication UX (recommendations, 教程和示例)?

node.js - 使用 node.js、nano 和 CouchDB 进行身份验证

.net-core - F#.fsx 脚本 : how to register 'paket' as package manager?

http - OpenID Connect 是否标准化了 OAuth 2 授权端点?