首页 > 解决方案 > net core 2.2 到 3.0 身份验证迁移 AddOpenIdConnect

问题描述

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

关联

那么.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#asp.net-core

解决方案



推荐阅读