[英]net core 2.2 to 3.0 authentication migration AddOpenIdConnect
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:目前我正在将asp net core 2.2 web站点升级到使用Identity Server 4身份验证的net core 3.0,并发现阻止我完成此任务的问题:在.net core 3.0中, OpenIdConnectExtensions中没有关于它的AddOpenIdConnect方法(文档是clear :
So is there any substitute in .net core 3.0?那么.net core 3.0有什么替代品吗?
Startup.cs that works in net core 2.2在 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;
})
If you examine the 2.2 -> 3.0 migration document here: https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30?view=aspnetcore-3.0&tabs=visual-studio如果您在此处查看 2.2 -> 3.0 迁移文档: https://docs.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://docs.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:您将在添加 package 引用以删除程序集部分( 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 package 来支持这个:
https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.OpenIdConnect https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.OpenIdConnect
For recognizing AddOpenIdConnect , from version 3.0 onwards, you must install package:要识别AddOpenIdConnect ,从 3.0 版开始,您必须安装 package:
Microsoft.AspNetCore.Authentication.OpenIdConnect
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.