使用Microsoft.Owin.Security.OpenIdConnect和“代码”身份验证流

时间:2018-10-05 09:18:29

标签: openid-connect

我一直在研究客户站点之一上的更改请求,以将OpenIdConnect身份验证从“隐式”流程更改为“代码”流程。它似乎只执行身份验证过程的一部分。

有人能做到这一点吗?

这是我的代码:

public void ConfigureAuth(IAppBuilder app)
{
    app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

    app.UseCookieAuthentication(new CookieAuthenticationOptions());

    var options = new OpenIdConnectAuthenticationOptions
    {
        ClientId = WebConfigurationManager.AppSettings["OpenIdClientId"],
        ClientSecret = WebConfigurationManager.AppSettings["OpenIdClientSecret"],
        Authority = WebConfigurationManager.AppSettings["OpenIdAuthority"],
        Scope = "openid profile email",
        ResponseType = "code",

        Notifications = new OpenIdConnectAuthenticationNotifications
        {
            RedirectToIdentityProvider = n =>
            {
                return Task.FromResult(0);
            },
            AuthenticationFailed = x =>
            {
                return Task.FromResult(0);
            },
            AuthorizationCodeReceived = x =>
            {
                //Only used in "Hybrid" flow
                return Task.FromResult(0);
            },
            MessageReceived = x =>
            {
                return Task.FromResult(0);
            },
            SecurityTokenReceived = x =>
            {
                return Task.FromResult(0);
            },
            SecurityTokenValidated = n =>
            {
                return Task.FromResult(0);
            }
        }
    };

    app.UseOpenIdConnectAuthentication(options);
}

0 个答案:

没有答案