【发布时间】:2018-04-30 16:41:44
【问题描述】:
我会说带有身份验证的经典 ASP.NET Core 2.0 应用程序包括在 Startup.cs 文件的 ConfigureServices 方法中添加所需的身份验证服务:
services.AddAuthentication().AddFacebook(facebookOptions =>
{
facebookOptions.AppId = Configuration["Authentication:Facebook:AppId"];
facebookOptions.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
});
只要在调用ConfigurationServices 方法时知道身份验证配置并且对所有请求都相同,就可以了。
我们的案例需要不同的身份验证配置,比如说基于主机名:
company1.example.com // has own authentication configuration
company2.example.com // has own (probably different) authentication
更多详情,company1 仅配置了 Facebook,company2 仅配置了 Google 身份验证。
问题:是否可以对每个主机或每个请求进行不同的身份验证?例如,一旦我知道公司,我就可以加载和使用与此请求相关的身份验证配置。
【问题讨论】:
标签: c# authentication asp.net-core-2.0