.NET Framework OpenIdConnect程序包中缺少OnRedirectToIdentityProvider事件

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

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

tianjing_anbey 回答:.NET Framework OpenIdConnect程序包中缺少OnRedirectToIdentityProvider事件

您可以在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);
        }
    }
});
本文链接:https://www.f2er.com/3116906.html

大家都在问