网络核心2.2到3.0身份验证迁移AddOpenIdConnect

时间:2019-10-09 11:54:17

标签: c# asp.net-core

当前,我正在将ASP Net Core 2.2网站升级到使用Identity Server 4身份验证的Net Core 3.0,发现导致我无法完成此任务的问题:在.net core 3.0中,没有 AddOpenIdConnect OpenIdConnectExtensions 中的strong>方法(文档对此很清楚:

Link

.net core 3.0有什么替代品吗?

在网络核心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;                    
                    })

1 个答案:

答案 0 :(得分:6)