IdentityServer 身份验证端点 -> error=invalid_request failureReason="STATUS_CODE"

IdentityServer Authentication Endpoint -> error=invalid_request failureReason="STATUS_CODE"

我目前正在为一项第三方服务实施 SSO。该服务不支持 OIDC 或 OAuth,因此我需要实现它的专有性。我拥有的是处理请求的中间件。当它将请求识别为来自第三方应用程序的登录请求时,它会创建授权 link 并将其重定向到 [identityserver]/connect/authorize,这是授权端点。然后服务器应该还给我 jwt 令牌,我会处理它。不管怎样,身份服务器给我错误,当我查看日志文件时,我可以看到 failureReason="STATUS_CODE"。但是Response.Redirect()设置了状态码302,应该就好了,不应该吗?

客户端设置正常。我正在使用隐式流。但是,对于 AuthorizationCode 或 ClientCredentials,将我发送到错误页面并显示消息:客户端应用程序未知或未获得授权。状态代码 204。

中间件片段:

            string url = $"{context.Request.Scheme}://{context.Request.Host}";
            DiscoveryClient discoveryClient = new DiscoveryClient("https://localhost:44300/");
            DiscoveryResponse doc = await discoveryClient.GetAsync();

            AuthorizeRequest authorizeRequest = new AuthorizeRequest(doc.AuthorizeEndpoint);
            string authorizeUrl = authorizeRequest.CreateAuthorizeUrl(
                clientId: "zendesk",
                responseType: "id_token token",
                scope: "openid email profile",
                redirectUri: $"{url}/zendesk/authenticated",
                state: Base64Url.Encode(returnTo.ToBytes()));

            context.Response.Redirect(authorizeUrl);

            return;

重定向 link:

https://localhost:44300/connect/authorize?client_id=zendesk&response_type=id_token+token&scope=openid+email+profile&redirect_uri=https%3A%2F%2Flocalhost%3A44327%2Fzendesk%2Fauthenticated&state=[64encodedValue]

结果link:

https://localhost:44327/zendesk/authenticated#error=invalid_request&state=[64encodedValue]

感谢任何提示,我在这里陷入死胡同。

我收到了另一个包含有用信息的日志:

Nonce required for implicit and hybrid flow with openid scope
{
...
,
"SubjectId": "unknown",
"ResponseType": "id_token token",
"ResponseMode": "form_post",
"Flow": "Implicit",
"RequestedScopes": "openid email profile",
"State": "...",
"Raw": {
"client_id": "...",
"response_type": "id_token token",
"scope": "openid email profile",
"redirect_uri": "...",
"state": "...",
"response_mode": "form_post"
}

而且我还是决定使用其他流程。

在您的 /authorize 请求中添加 nonce 参数。

OpenId Connect 标准说它是可选的,但 IdentityServer3 将它作为必需参数。 –