Identity Server 4会重定向到AccountController
进行登录, 一旦用户被验证后,将调用HttpContext.SignInAsync
方法,然后执行返回ReturnUrl的Redirect操作。
但是,在某些情况下,需要将内部服务器错误
发送回原始客户端,而不是在View中显示给最终用户。在这种情况下,我想发出标准的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.