在ASP.NET Core 3中允许多种类型的身份验证方案

时间:2020-04-11 00:50:50

标签: c# asp.net-mvc authentication asp.net-core auth0

我一直在尝试使用Open ID Connect(.Net Core的Auth0 quick start sample)。我有一个用例,有时我仍然想使用默认的身份提供程序方案“ Identity.Application”登录到网站。我可以使用OpenIdConnect或Auth0或默认身份来配置我的startup.cs类。

使用OpenIdConnect要求我使用CookieAuthenticationDefaults方案:

.AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            })

使用默认方案:

.AddAuthentication()

我是否可以同时允许这两种方案,以便我可以使用其中任何一种登录?

认为我将需要在运行时交换中间件,但不知道那是否有可能。

0 个答案:

没有答案