目前我正在将 asp net core 2.2 网站升级到使用 Identity Server 4 身份验证的 net core 3.0 并发现阻止我完成此任务的问题:在 .net core 3.0 中没有 AddOpenIdConnectOpenIdConnectExtensions 中的 strong> 方法(文档对此很清楚:
那么.net core 3.0有替代品吗?
适用于 net core 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;
})
最佳答案
如果您在此处检查 2.2 -> 3.0 迁移文档: https://learn.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio
您将在为删除的程序集添加包引用部分 (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) 中看到现在有一个 nuget 包来支持它:
https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.OpenIdConnect
关于c# - net core 2.2 到 3.0 身份验证迁移 AddOpenIdConnect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58303568/