【问题标题】:Correlation failed on Identity Server 4Identity Server 4 上的关联失败
【发布时间】:2020-05-01 02:15:11
【问题描述】:

我有一个配置了 OpenIdConnect 到 Azure AD 的 Identity Server 4

当用户单击登录按钮时,IS4 重定向到 Azure AD,并在回调到 IS4 时显示此错误:

这是我向邮递员请求令牌的方式:

注意回调url是移动应用格式。

这是我的配置:

services.AddAuthentication()
        .AddCookie(options => new CookieAuthenticationOptions
        {
            ExpireTimeSpan = TimeSpan.FromHours(12),
            SlidingExpiration = false,
            Cookie = new CookieBuilder
            {
                Path = "",
                Name = "MyCookie"
            }
        }).AddOpenIdConnect(options =>
        {
            options.ClientId = configuration["OpenIdConnect:ClientId"];
            options.Authority = configuration["OpenIdConnect:Authority"];
            options.SignedOutRedirectUri = configuration["OpenIdConnect:PostLogoutRedirectUri"];
            options.CallbackPath = configuration["OpenIdConnect:CallbackPath"];
            options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
            options.Resource = configuration["OpenIdConnect:Resource"];
            options.ClientSecret = configuration["OpenIdConnect:ClientSecret"];
            options.SaveTokens = true;
            options.RequireHttpsMetadata = false;

            options.TokenValidationParameters = new TokenValidationParameters
            {
                NameClaimType = "name",
                RoleClaimType = "role"
            };
            options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;

        });

这是我的参数:

  "OpenIdConnect": {
    "ClientId": "xxxxxxxxxx",
    "Authority": "https://login.microsoftonline.com/xxxxxxxxxx/",
    "PostLogoutRedirectUri": "https://uri-of-my-identity-server.azurewebsites.net",
    "CallbackPath": "/signin-oidc",
    "ResponseType": "code id_token",
    "Resource": "https://graph.microsoft.com/",
    "ClientSecret": "my-secret"
  },

注意:此错误仅发生在 Azure 环境(不是本地)

注意:在 Xamarin 应用程序上,当 Azure 返回 IS4 同意屏幕时,它会显示以下消息:

【问题讨论】:

  • 您可以尝试将CallbackPath更改为/signin-oidc-aad,并将AAD应用重定向url修改为https://uri-of-my-identity-server.azurewebsites.net/signin-oidc-aad
  • @NanYu 我在我的 IS4 参数和 Azure AD 配置上配置了新的 url(带有 -aad 字符串)但我得到了同样的错误
  • AuthenticationController 回调的代码在哪里

标签: .net-core oauth-2.0 identityserver4


【解决方案1】:

可能是您的客户端和 Azure 之间的网络存在问题。某个端口尚未打开或介于两者之间的负载均衡器。

When decryption fails, state is null, thus resulting in a Correlation failed: state not found error. In our case, decryption failed because different keys were used for encryption/decryption, a pretty common problem when deploying behind a load balancer.

【讨论】:

    猜你喜欢
    • 2020-05-02
    • 2018-07-23
    • 2019-04-18
    • 2020-12-27
    • 1970-01-01
    • 2018-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多