具有外部提供程序的Identityserver4,重定向到提供程序时会生成不同的“状态”

时间:2019-12-14 02:29:34

标签: asp.net-core oauth asp.net-core-2.0 identityserver4 openid

使用asp.net core 3.0和IdentityServer4,我们使用一个自定义的外部提供程序,该提供程序还实现了OAuth2 / OpenId和PKCE的授权代码流。 重定向时在IdentityServer ExternlController.Challenge中

public async Task<IActionResult> Challenge(string provider, string returnUrl)
    {
        if (string.IsNullOrEmpty(returnUrl)) returnUrl = "~/";

        // validate returnUrl - either it is a valid OIDC URL or back to a local page
        if (Url.IsLocalUrl(returnUrl) == false && _interaction.IsValidReturnUrl(returnUrl) == false)
        {
            // user might have clicked on a malicious link - should be logged
            throw new Exception("invalid return URL");
        }

        if (AccountOptions.WindowsAuthenticationSchemeName == provider)
        {
            // windows authentication needs special handling
            return await ProcessWindowsLoginAsync(returnUrl);
        }

        // start challenge and roundtrip the return URL and scheme 
        var props = new AuthenticationProperties
        {
            RedirectUri = Url.Action(nameof(Callback)),
            Items =
            {
                { "returnUrl", returnUrl },
                { "scheme", provider },
            }
        };

        return Challenge(props, provider);
    }

重定向URL“状态”查询参数获取生成的新值,而不是使用客户端提供的原始“状态”参数值,并且该值从外部提供程序往返返回给我们,再返回至客户端应用,当然无法验证状态。 是否有一些我们可能会缺少的配置?我应该以为它传递了原始的“状态”值。

0 个答案:

没有答案