Kubernetes: The input does not contain any JSON tokens
Hi,
I followed the steps described here https://simpleidserver.com/docs/installation/#kubernetes to deploy simpleidserver to Docker Desktop Kubernetes (not Minikube). When I try to access the URL https://website.sid.svc.cluster.local/master/clients I get an HTTP error 500. The log of the website shows these error messages:
at SimpleIdServer.IdServer.Website.Middlewares.RealmMiddleware.InvokeAsync(HttpContext context) in C:\Projects\SimpleIdServer\src\IdServer\SimpleIdServer.IdServer.Website\Infrastructures\RealmMiddleware.cs:line 69
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HN7UEGDSLNJK", Request id "0HN7UEGDSLNJK:00000006": An unhandled exception was thrown by the application.
System.InvalidOperationException: The exception handler configured on ExceptionHandlerOptions produced a 404 status response. This InvalidOperationException containing the original exception was thrown since this is often due to a misconfigured ExceptionHandlingPath. If the exception handler is expected to return 404 status responses then set AllowStatusCode404Response to true.
---> System.Text.Json.JsonReaderException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
at System.Text.Json.Utf8JsonReader.Read()
at System.Text.Json.JsonDocument.Parse(ReadOnlySpan`1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack)
at System.Text.Json.JsonDocument.ParseUnrented(ReadOnlyMemory`1 utf8Json, JsonReaderOptions readerOptions, JsonTokenType tokenType)
at System.Text.Json.JsonDocument.ParseValue(ReadOnlyMemory`1 json, JsonDocumentOptions options)
at System.Text.Json.Nodes.JsonNode.Parse(String json, Nullable`1 nodeOptions, JsonDocumentOptions documentOptions)
at SimpleIdServer.IdServer.Website.WebsiteHttpClientFactory.GetAccessToken(String realm) in C:\Projects\SimpleIdServer\src\IdServer\SimpleIdServer.IdServer.Website\WebsiteHttpClientFactory.cs:line 87
at SimpleIdServer.IdServer.Website.WebsiteHttpClientFactory.Build(String realm) in C:\Projects\SimpleIdServer\src\IdServer\SimpleIdServer.IdServer.Website\WebsiteHttpClientFactory.cs:line 42
at SimpleIdServer.IdServer.Website.Middlewares.RealmMiddleware.GetRealms() in C:\Projects\SimpleIdServer\src\IdServer\SimpleIdServer.IdServer.Website\Infrastructures\RealmMiddleware.cs:line 88
at SimpleIdServer.IdServer.Website.Middlewares.RealmMiddleware.InvokeAsync(HttpContext context) in C:\Projects\SimpleIdServer\src\IdServer\SimpleIdServer.IdServer.Website\Infrastructures\RealmMiddleware.cs:line 69
at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.HandleException(HttpContext context, ExceptionDispatchInfo edi)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
The Docker compose solution https://simpleidserver.com/docs/installation/#docker works for me... What do I miss?
Hello,
There is indeed a mistake in the sid-kubernetes.yaml file.
In the website-deploy service, set the property DefaultSecurityOptions__Issuer to https://idserver.sid.svc.cluster.local, and it should work.
Can confirm that did the trick. Thanks.
What about the DefaultSecurityOptions__Issuer for the credentialissuerwebsite-deploy? See https://github.com/simpleidserver/SimpleIdServer/blob/master/sid-kubernetes.yaml#L401
The value of DefaultSecurityOptions_Issuer for credentialissuerwebsite-deploy must remain unchanged and should follow this format: https://<URL>/master.
The difference between credentialissuerwebsite-deploy and website-deploy is that website-deploy supports realms and uses a custom version of the Microsoft.AspNetCore.Authentication.OpenIdConnect NuGet package.