【问题标题】:OnRedirectToIdentityProvider event missing in .NET Framework OpenIdConnect package.NET Framework OpenIdConnect 包中缺少 OnRedirectToIdentityProvider 事件
【发布时间】:2020-03-08 05:59:58
【问题描述】:

Microsoft.AspNetCore.Authentication.OpenIdConnect 包中,OpenIdConnectEvents 类中有许多事件,尤其是 OnRedirectToIdentityProvider(Microsoft docs) 但对于 .NET Framework,我们有 Microsoft.Owin。 Security.OpenIdConnect 包,我在其中找不到任何这些事件。有人知道是否可以在 .NET Framework 中获得这样的功能?

我们使用身份服务器 4 进行身份验证和 .NET Framework 4.7.2 mvc 客户端。我的目标是连接到最终用户被重定向到授权进行身份验证的位置(在客户端)。

【问题讨论】:

    标签: c# asp.net-mvc asp.net-core identityserver4 openid-connect


    【解决方案1】:

    您可以在Microsoft.Owin.Security.OpenIdConnect 中使用OpenIdConnectAuthenticationNotifications class

    app.UseCookieAuthentication(new CookieAuthenticationOptions
    {
        AuthenticationType = "Cookies"
    });
    
    
    app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
    {
        Authority = "https://localhost:44319/identity",
    
        ClientId = "mvc",
        Scope = "openid profile roles sampleApi",
        ResponseType = "id_token token",
        RedirectUri = "https://localhost:44319/",
    
        SignInAsAuthenticationType = "Cookies",
        UseTokenLifetime = false,
    
        Notifications = new OpenIdConnectAuthenticationNotifications
        {
            SecurityTokenValidated = async n =>
            {
    
            },
    
            RedirectToIdentityProvider = n =>
            {
    
    
                return Task.FromResult(0);
            }
        }
    });
    

    【讨论】:

    • 它正在工作!谢谢!所以有通知而不是事件..ok)
    猜你喜欢
    • 2012-10-23
    • 2020-12-14
    • 1970-01-01
    • 1970-01-01
    • 2018-03-15
    • 2016-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多