[英]ABP 401 response from API instead of redirect
I have the same problem as this: https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=4865 , but I have ABP v2.1 with module-zero-core-template. 我有与此相同的问题: https ://forum.aspnetboilerplate.com/viewtopic.php?f =5& t=4865,但是我有ABP v2.1和module-zero-core-template。
I'm using Web.Mvc project as my startup project and I want to make API calls. 我将Web.Mvc项目用作启动项目,并且想进行API调用。
When I perform an unauthorized request to the API, I got a "200 OK" response instead of a "401". 当我对API执行未经授权的请求时,我得到的响应是“ 200 OK”,而不是“ 401”。 Where did I make a mistake?
我在哪里弄错了?
ABP v2.x / module-zero-core-template v2.x ABP v2.x /模块零核心模板v2.x
Modify IdentityRegistrar
in .Core project: 在.Core项目中修改
IdentityRegistrar
:
// Before
services.AddAbpIdentity<Tenant, User, Role>()
// After
services.AddAbpIdentity<Tenant, User, Role>(options =>
{
options.Cookies.ApplicationCookie.AutomaticChallenge = false;
})
Reference: https://github.com/aspnet/Security/issues/804 参考: https : //github.com/aspnet/Security/issues/804
ABP v3.x / module-zero-core-template v3.0.0 – v3.4.0 ABP v3.x /模块零核心模板v3.0.0 – v3.4.0
Modify AuthConfigurer
in .Web.Mvc / .Web.Host project: 修改
AuthConfigurer
在.Web.Mvc / .Web.Host项目:
// Before
services.AddAuthentication()
// After
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = "JwtBearer";
options.DefaultChallengeScheme = "JwtBearer";
})
Reference: 92b6270
in module-zero-core-template v3.5.0 参考:模块零核心模板v3.5.0中的
92b6270
该授权文档将为您提供每一个细节。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.