我使用的是带有identityserver和混合流的vue cli中间件。
在Ajax调用中,我已手动重定向到identityprovider,如下所示。
options.Events.OnRedirectToIdentityProvider = context =>
{
if (context.Request.Path.StartsWithSegments("/api"))
{
if (context.Response.StatusCode == (int)HttpStatusCode.OK)
{
context.ProtocolMessage.State = options.StateDataFormat.Protect(context.Properties);
context.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
context.Response.Headers["Location"] = context.ProtocolMessage.CreateAuthenticationRequestUrl();
}
context.HandleResponse();
}
return Task.CompletedTask;
};
从identityserver回调时,我发现下面有错误。
KeyNotFoundException:字典中不存在给定的密钥“OpenIdConnect.Code.RedirectUri”。
下面是调用堆栈。
Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler.HandleRequestAsync()
Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext上下文)
Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext上下文)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext上下文)
我正在使用repo下面的identityserver。
https://github.com/IdentityServer/IdentityServer4
我的叉式回购(上面有代码)
https://github.com/hnviradiya/asp-net-core-vue-starter