【发布时间】:2014-11-25 04:38:46
【问题描述】:
我创建了一个 custom BasicAuthenticationMiddleware,它使用 BasicAuthenticationHandler 来验证从客户端到 WebAPI 的请求。
BasicAuthenticationHandler 派生自 AuthenticationHandler 基类。
一切正常,我实现了
AuthenticateCoreAsync 验证逻辑发生在哪里
ApplyChallengeResponseAsync 如果请求未经过身份验证,逻辑会将 WWW-Authenticate 标头发送到客户端。
我现在想要实现的是在响应中设置一个自定义主体(IOwinResponse,在 ApplyChallengeResponseAsync 内部,带有一个自定义对象,例如:
{
Code="999",
Description="My failing reason"
AdditionalInfo = "My additional infos"
}
而不是像标准消息那样
{
message="Authorization has been denied for this request."
}
您对此有什么建议吗?
谢谢
【问题讨论】:
标签: asp.net-mvc asp.net-web-api owin asp.net-web-api2