【发布时间】:2019-04-19 20:02:05
【问题描述】:
在 Azure 应用服务论坛中发布此内容并没有收到任何回复,所以...
框架是 4.7.1
应用程序是带有两个 Web API 控制器的 ASP.Net Web 表单。
网站和 HealthCheck 控制器应该允许匿名请求。
另一个控制器应使用证书作为凭据通过 Azure Active Directory 进行身份验证。
应用服务中的身份验证设置为
- 允许匿名请求(无操作)
- 身份验证提供程序设置为 Azure Active Directory
- 管理模式设置为 Express
- 证书已添加到管理应用程序中
唯一的问题是,当匿名请求到达安全控制器时,会返回 HTTP 404 而不是 401。
如果发出经过身份验证的请求,则返回 HTTP 200。 我是否缺少一些配置设置?
这是 Application_Start 中 Global.asax.cs 中的路线图
RouteTable.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = System.Web.Http.RouteParameter.Optional }
);
这里是authorization.json文件
{
"routes": [{
"path_prefix": "/",
"policies": { "unauthenticated_action": "AllowAnonymous" }
},
{
"path_prefix": "/api",
"policies": { "unauthenticated_action": "RejectWith401" }
},
{
"http_methods": [ "GET"],
"path_prefix": "/api/HealthCheck",
"policies": { "unauthenticated_action": "AllowAnonymous" }
}]
}
【问题讨论】:
标签: azure authentication webforms asp.net-web-api2 azure-web-app-service