在特殊情况下,我无法使AbpMvcAuthorize
属性正常工作。
我有一些自定义身份验证机制(带有自定义AuthenticationScheme
),用于登录用户。
为此,我实现了AuthenticationHandler<MyCustomAuthenticationOptions>
并覆盖了HandleAuthenticateAsync
方法,并将其从Module-zero中注册到了AuthConfigurer.Configure
方法中:
services.AddAuthentication(o => o.AddScheme("amx", b => b.HandlerType = typeof (MyCustomAuthenticationHandler)));
现在,如果我有这个:
[Authorize(AuthenticationSchemes = "amx")]
public string GetTest()
{
return "OK";
}
并使用我的特殊amx标头发出请求,该请求正在运行,并且只有在指定该方法时我才能访问该方法。
如果我在做同样的事情:
[AbpMvcAuthorize(AuthenticationSchemes = "amx")]
public string GetTest()
{
return "OK";
}
它不再工作,并且我得到401未经授权的结果,并且在调试模式下,我从不输入自定义AuthenticationHandler
。
似乎AbpMvcAuthorize
属性是在我的自定义AuthenticationHandler
之前执行的,还是它没有读取AuthenticationScheme
属性?
知道我做错什么了吗?
谢谢
答案 0 :(得分:0)
我在他们的Github上问:https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3778
并被告知目前无法实现此操作,因为AbpMvcAuthorize
无法读取AuthenticationScheme
属性。
我将尝试通过一些政策来实现它