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

标签 c# asp.net-core

目前我正在将 asp net core 2.2 网站升级到使用 Identity Server 4 身份验证的 net core 3.0 并发现阻止我完成此任务的问题:在 .net core 3.0 中没有 AddOpenIdConnectOpenIdConnectExtensions 中的 strong> 方法(文档对此很清楚:

Link

那么.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;                    
                    })

最佳答案

关于c# - net core 2.2 到 3.0 身份验证迁移 AddOpenIdConnect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58303568/

相关文章:

c# - 代码生成器错误 : There is no entity type on DbContext

c# - 相当于.Net Core中的HttpResponse.StatusDescription来设置状态码描述

ASP.NET Core 以单一形式使用两个模型

c# - 我应该在哪里启动 ASP.NET Core 中的持久后台任务?

c# - 通过 Open XML 将数据导出到支持宏的 Excel

c# - 哪个 .NET ORM 对 PostgreSQL 数据库的支持最好

c# - 两个可枚举之间的相等性

asp.net-mvc - Hangfire (v1.8.4) 图标未显示

c# - 至少一个对象必须实现 IComparable

c# - 如何在 ListView 控件的 ItemTemplate 中调用函数