IdentityServer / IdentityServer4.Templates

dotnet new templates for IdentityServer4
Apache License 2.0
695 stars 229 forks source link

Unable to create client in Admin #75

Closed GioviQ closed 4 years ago

GioviQ commented 4 years ago

dotnet new is4admin

Try with Chrome, Edge, Internet Explorer Annotazione 2020-03-22 115158

leastprivilege commented 4 years ago

@scottbrady91

scottbrady91 commented 4 years ago

@JosephHarvey

forgetwholesale commented 4 years ago

ugh.

I debugged into this issue, and apparently there was some json being returned which could not be parsed.

That json included text for the call stack for an exception. Which looks like this (only including the top few lines):

System.InvalidOperationException: Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead. ↵ at Microsoft.AspNetCore.Server.IIS.Core.HttpRequestStream.Read(Byte[] buffer, Int32 offset, Int32 count) ↵ at Microsoft.AspNetCore.Server.IIS.Core.WrappingStream.Read(Byte[] buffer, Int32 offset, Int32 count) ↵ at System.IO.StreamReader.ReadBuffer() ↵ at System.IO.StreamReader.ReadToEnd() ↵ at IdentityExpress.Manager.Api.Formatters.JsonInputFormatter`1.ReadRequestBodyAsync(InputFormatterContext context, Encoding encoding)

Googling the InvalidOperationException turns up the following stackoverflow link: https://stackoverflow.com/questions/47735133/asp-net-core-synchronous-operations-are-disallowed-call-writeasync-or-set-all

So, the fix for this is to add the "iis.AllowSynchronousIO = true;" line below to the code within Startup.cs:

        // configures IIS in-proc settings
        services.Configure<IISServerOptions>(iis =>
        {
            iis.AuthenticationDisplayName = "Windows";
            iis.AutomaticAuthentication = false;
            iis.AllowSynchronousIO = true;
        });

Decompiling the JsonInputFormatter class (in the IdentityExpress.Manager.Api assembly) it looks liek the highlighted line below is likely the cause:

image

The highlighted statement (streamReader.ReadToEnd()) should probably be replaced with an await streamReader.ReadToEndAsync() call, and the ReadRequestBodyAsync be marked as an async method.

joe-harvey-rsk commented 4 years ago

Thanks for investigating this.

We plan to release AdminUI 3.0 early next week, alongside that we will be updating community edition with our latest AdminUI changes which will contain a fix for this issue.

scottbrady91 commented 4 years ago

Thanks again for reporting this. This has been addressed in #76.

leastprivilege commented 4 years ago

Working on templates this week. Will release a new version with the Admin UI bits.