答案 0 :(得分: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