OIDC登录重定向回传500错误(signin-oidc)

时间:2019-01-25 14:17:16

标签: oidc .net-core-2.2

我正在将.NET Core 2.2用于我的webapi应用程序! 它在我的本地计算机上运行没有问题,在暂存环境中,仅成功登录后,我收到“ Correlation failed(未知位置)”错误消息。 (登录发生在另一个域上,并重定向回我的应用程序)

在我的startup.cs文件中添加以下代码之前,成功登录后我什至没有重定向到我的应用程序,现在我收到500错误消息重定向到我的应用程序。

        var forwardingOptions = new ForwardedHeadersOptions()
        {
            ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
        };
        forwardingOptions.KnownNetworks.Clear(); //its loopback by default
        forwardingOptions.KnownProxies.Clear();
        app.UseForwardedHeaders(forwardingOptions);

enter image description here

           .AddOpenIdConnect("oidc", options =>
            {
                options.SignInScheme = "Cookies";

                options.Authority = tokenServiceConfig.Authority;
                options.RequireHttpsMetadata = tokenServiceConfig.RequireHttpsMetadata;

                options.SignedOutCallbackPath = "/Inloggen/LoggedOut";

                options.Scope.Add("somescope1");
                options.Scope.Add("somescope2");
                options.Scope.Add("somescope3");

                options.ClientId = tokenServiceConfig.ClientId;
                options.ClientSecret = tokenServiceConfig.ClientSecret;
                options.ResponseType = "code id_token";
                options.ResponseMode = "form_post";

                options.GetClaimsFromUserInfoEndpoint = true;
                options.SaveTokens = true;

                options.TokenValidationParameters.ValidateIssuer = true;
                options.TokenValidationParameters.ValidateLifetime = true;
                options.TokenValidationParameters.ClockSkew = TimeSpan.Zero;
            });

1 个答案:

答案 0 :(得分:0)

ASPNET Core OIDC Correlation Failed

在启动时的Configure方法中,需要添加它以处理http / https冲突。

app.Use((context, next) =>
{
    context.Request.Scheme = "https";
    return next();
});