Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubernetes: The input does not contain any JSON tokens #804

Open
schwichti opened this issue Nov 6, 2024 · 4 comments
Open

Kubernetes: The input does not contain any JSON tokens #804

schwichti opened this issue Nov 6, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@schwichti
Copy link

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?

@simpleidserver simpleidserver self-assigned this Nov 7, 2024
@simpleidserver simpleidserver added the bug Something isn't working label Nov 7, 2024
@simpleidserver simpleidserver moved this to In Progress in Release 5.0.3 Nov 7, 2024
thabart added a commit that referenced this issue Nov 8, 2024
@simpleidserver
Copy link
Owner

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.

@simpleidserver simpleidserver closed this as completed by moving to Done in Release 5.0.3 Nov 8, 2024
@simpleidserver simpleidserver reopened this Nov 8, 2024
@schwichti
Copy link
Author

schwichti commented Nov 8, 2024

Can confirm that did the trick. Thanks.

@schwichti
Copy link
Author

What about the DefaultSecurityOptions__Issuer for the credentialissuerwebsite-deploy? See https://github.com/simpleidserver/SimpleIdServer/blob/master/sid-kubernetes.yaml#L401

@simpleidserver
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

2 participants