2017-10-18 90 views

回答

0

是的,这是可能的。

您需要确保在ConfigureServices中正确设置了认证方案。

services.AddAuthentication() 
     .AddCookie("MyCookieAuthenticationScheme", options => { 

     }) 
     .AddAnotherHandler("AnotherName", options => { }); 

然后为每个控制器/动作,你将需要指定符合条件的计划

例子:

[Authorize(AuthenticationSchemes = "Scheme1")] 
public IActionResult Test1() { } 


[Authorize(AuthenticationSchemes = "Scheme2")] 
public IActionResult Test2() { } 


[Authorize(AuthenticationSchemes = "Scheme1,Scheme2")] 
public IActionResult Test3() { } 

如果需要,您还可以创建自己的验证处理程序。

祝你好运, Seb

相关问题