来自 API 的 ABP 401 响应而不是重定向
ABP 401 response from API instead of redirect
我遇到了与此相同的问题:https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=4865,但我有 ABP v2.1 和模块零核心模板。
我正在使用 Web.Mvc 项目作为我的启动项目,我想进行 API 调用。
当我对 API 执行未经授权的请求时,我收到了“200 OK”响应而不是“401”。我哪里弄错了?
这份 authorization 文档将为您提供每一个细节。
ASP.NET核心1.x
ABP v2.x / module-zero-core-template v2.x
在.Core项目中修改IdentityRegistrar
:
// Before
services.AddAbpIdentity<Tenant, User, Role>()
// After
services.AddAbpIdentity<Tenant, User, Role>(options =>
{
options.Cookies.ApplicationCookie.AutomaticChallenge = false;
})
参考:https://github.com/aspnet/Security/issues/804
ASP.NET核心2.0
ABP v3.x / module-zero-core-template v3.0.0 – v3.4.0
修改AuthConfigurer
在.Web.Mvc/.Web.Host项目:
// Before
services.AddAuthentication()
// After
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = "JwtBearer";
options.DefaultChallengeScheme = "JwtBearer";
})
参考:92b6270
in module-zero-core-template v3.5.0
我遇到了与此相同的问题:https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=4865,但我有 ABP v2.1 和模块零核心模板。
我正在使用 Web.Mvc 项目作为我的启动项目,我想进行 API 调用。
当我对 API 执行未经授权的请求时,我收到了“200 OK”响应而不是“401”。我哪里弄错了?
这份 authorization 文档将为您提供每一个细节。
ASP.NET核心1.x
ABP v2.x / module-zero-core-template v2.x
在.Core项目中修改IdentityRegistrar
:
// Before
services.AddAbpIdentity<Tenant, User, Role>()
// After
services.AddAbpIdentity<Tenant, User, Role>(options =>
{
options.Cookies.ApplicationCookie.AutomaticChallenge = false;
})
参考:https://github.com/aspnet/Security/issues/804
ASP.NET核心2.0
ABP v3.x / module-zero-core-template v3.0.0 – v3.4.0
修改AuthConfigurer
在.Web.Mvc/.Web.Host项目:
// Before
services.AddAuthentication()
// After
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = "JwtBearer";
options.DefaultChallengeScheme = "JwtBearer";
})
参考:92b6270
in module-zero-core-template v3.5.0