【发布时间】:2019-09-11 17:54:02
【问题描述】:
Identity Server 4 重定向到 AccountController 进行登录,一旦验证用户,就会调用 HttpContext.SignInAsync 方法,然后执行重定向到 ReturnUrl。
但是,在某些情况下,需要将internal server error 发送回原始客户端,而不是在视图中显示给最终用户。在这种情况下,我想发出标准的OAuth2 错误响应,但我没有看到这样做的方法。
更新:
我添加了更多信息。我指的是 OAuth 2.0 规范的这一部分。 Identity Server 可以这样做还是我必须从 RedirectUri 手动构建 URL。
基于此规范的 RedirectUri 示例如下:
例如,授权服务器通过发送以下 HTTP 响应来重定向用户代理:
HTTP/1.1 302 Found
Location: https://client.example.com/cb?error=access_denied&state=xyz
OAuth 2.0 规范的第 4.1.2.1 节规定:
If the request fails due to a missing, invalid, or mismatching
redirection URI, or if the client identifier is missing or invalid,
the authorization server SHOULD inform the resource owner of the
error and MUST NOT automatically redirect the user-agent to the
invalid redirection URI.
If the resource owner denies the access request or if the request
fails for reasons other than a missing or invalid redirection URI,
the authorization server informs the client by adding the following
parameters to the fragment component of the redirection URI using the
"application/x-www-form-urlencoded" format.
【问题讨论】:
-
也许您也可以将其作为问题发布到IdentityServer4 repo(并在此处链接此q)。
-
当前流程中,出现这种情况时用户是否返回到客户端?您能否介绍一下这些“内部服务器错误”,它们发生的时间和原因?
-
你可以覆盖 AuthorizeRequestValidator 吗?
-
“内部服务器错误”只是“假设”。它实际上并没有发生。如果出现“内部服务器错误”,我如何将通知发送回中间件,以便它决定如何处理该过程。
标签: c# asp.net .net asp.net-web-api identityserver4