g.pickardou
g.pickardou

Reputation: 35812

Where is app.UseOpenIdConnectAuthentication() and OpenIdConnectMiddleware in ASP.NET Core 3?

Context

I am trying to migrate an application which uses app.UseOpenIdConnectAuthentication() but this extension method not found in package Microsoft.AspNetCore.Authentication.OpenIdConnect The actual source of this extension method uses the class OpenIdConnectMiddleware which also seems to be gone.

Question

How can I migrate this application?

Upvotes: 5

Views: 9651

Answers (1)

Alex Viana
Alex Viana

Reputation: 106

Change your startup file to the example below


public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            services.AddAuthentication(options =>
            {
                options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
                options.DefaultAuthenticateScheme = "oidc";
                options.DefaultSignInScheme = "Cookies";
            })
                .AddCookie()
                .AddOpenIdConnect(options =>
                {
                    options.Authority = "http://localhost:5000";
                    options.RequireHttpsMetadata = false;
                    options.ClientId = "mvc-client";
                    options.ClientSecret = "secret-key";
                    options.ResponseType = "id_token token";

                    options.Scope.Add("openid");
                    options.Scope.Add("profile");
                    options.Scope.Add("email");
                });
        }

Upvotes: 9

Related Questions