AlexSolovyov
AlexSolovyov

Reputation: 497

OnRedirectToIdentityProvider event missing in .NET Framework OpenIdConnect package

In Microsoft.AspNetCore.Authentication.OpenIdConnect package there is a number of events in OpenIdConnectEvents class, especially OnRedirectToIdentityProvider(Microsoft docs) But for .NET Framework we have Microsoft.Owin.Security.OpenIdConnect package in which i can`t find any of these events. Does anybody know if it is possible to obtain such functionality in .NET Framework?

We are using identity server 4 for authentication and .NET Framework 4.7.2 mvc client. My goal is to hook up into the place(on the client) where the end user is being redirected to the authority for proceeding with the authentification.

Upvotes: 0

Views: 2277

Answers (1)

Nan Yu
Nan Yu

Reputation: 27538

You can make use of OpenIdConnectAuthenticationNotifications class in Microsoft.Owin.Security.OpenIdConnect :

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);
        }
    }
});

Upvotes: 1

Related Questions