[Authorize(AuthenticationSchemes = AuthenticationSchemes.CookieAuthenticationScheme)]
public class MyController : ControllerBase
{
[HttpPost("ui")]
[ProducesResponseType(
(int) HttpStatusCode.Created)]
public async Task Action1()
{
}
[HttpPost]
[ProducesResponseType(
(int)HttpStatusCode.Created)]
[Authorize(AuthenticationSchemes = AuthenticationSchemes.JwtAuthenticationScheme)]
public async Task Action2()
{
}
}
我有这个控制器,其中Action2具有与Controller中的身份验证方案不同的Authorize属性。但是,当我使用有效的Cookie身份验证但使用无效的身份验证令牌来调用Action2时,那么Action2也会被授权-我期望得到401 / Unauthorized响应。
这是预期的行为吗?
使用Asp.net core 2.2
在ASP.NET Core 2.1之前,所有策略都将单独评估,并且都需要得到满足。