当前,我正在将ASP Net Core 2.2网站升级到使用Identity Server 4身份验证的Net Core 3.0,发现导致我无法完成此任务的问题:在.net core 3.0中,没有 AddOpenIdConnect OpenIdConnectExtensions 中的strong>方法(文档对此很清楚:
.net core 3.0有什么替代品吗?
在网络核心2.2中运行的Startup.cs
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;
})
答案 0 :(得分:6)
如果您在此处查看2.2-> 3.0迁移文档: https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio
您将在“为已删除的程序集添加程序包引用”部分(https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio#add-package-references-for-removed-assemblies)中看到现在有一个支持此功能的nuget程序包:
https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.OpenIdConnect