简体   繁体   English

net core 2.2 到 3.0 身份验证迁移 AddOpenIdConnect

[英]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 :

Link 关联

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;                    
                    })

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM