Currently I'm in upgrading asp net core 2.2 web site to net core 3.0 that uses Identity Server 4 authentication and found issue that stops me to finish this task: In .net core 3.0 there is no AddOpenIdConnect method in OpenIdConnectExtensions (docs are clear about it:
Link
So is there any substitute in .net core 3.0?
Startup.cs that works in net core 2.2
IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie(options =>
{
options.SlidingExpiration = true;
options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
})
.AddOpenIdConnect("oidc", options =>
{
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.Authority = "sso url";
options.RequireHttpsMetadata = false;
options.ClientId = "client_id";
options.ClientSecret = "secret";
options.ResponseType = $"{OpenIdConnectParameterNames.Code} {OpenIdConnectParameterNames.IdToken}";
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
})
ASP. NET Core ASP.NET Core 2.0 has a new model for authentication and Identity that simplifies configuration by using services. ASP.NET Core 1.x applications that use authentication or Identity can be updated to use the new model as outlined below.
Dotnet Core is the latest framework from Microsoft that lets you build apps once and deploy to not only Windows, but also Linux and Mac operating systems. It’s quickly gaining popularity, and as a result we’ve seen an increase in people wanting to add authentication to their Dotnet Core apps.
ASP.NET Core 2.0 Identity uses EF Core to interact with the database storing the authentication data. In order for the newly created app to work, there needs to be a database to store this data. After creating a new app, the fastest way to inspect the schema in a database environment is to create the database using EF Core Migrations.
Once you have your Dotnet Core environment installed, open a command prompt and enter the following to create a basic template for our sample app. It will create the new app in its own directory and download any reference libraries that are required.
If you examine the 2.2 -> 3.0 migration document here: https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio
You will see in the add package references for removed assemblies section (https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio#add-package-references-for-removed-assemblies) that there is now a nuget package to support this:
https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.OpenIdConnect
For recognizing AddOpenIdConnect, from version 3.0 onwards, you must install package:
Microsoft.AspNetCore.Authentication.OpenIdConnect
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With