DuendeSoftware / Support

Support for Duende Software products
20 stars 0 forks source link

Docker not working #1235

Closed schlechtOptimiziert closed 3 months ago

schlechtOptimiziert commented 3 months ago

Which version of Duende IdentityServer are you using? idk Which version of .NET are you using? 7 Describe the bug null refference error

To Reproduce https://github.com/schlechtOptimiziert/DockerTest Is a standard hosted Blazor Program created by vs2022 with minimal settings corrections to make it work.

clone => db setup (README) => "docker compose up" => try access the Site

Expected behavior idk why it is not working.

Would like to dockerize my test program. Not trying to publish the application, only trying to dockerize my Programm for my studies.

RolandGuijt commented 3 months ago

It looks like you created this solution using Microsoft's template to create a Blazor Wasm application with authentication. Unfortunately that is not the way IdentityServer should be used and the template has been removed in .NET 8.

We have a document that describes the problem and gives some hints on how to proceed. I recommend reading it to understand why the template doesn't work. Honestly I think the best thing to do after that is to start from scratch.

If all you need is authentication for this one Blazor application with a dedicated API you don't need IdentityServer at all. I would recommend setting up a server application that takes care of logging in and out. This is called the BFF pattern. You can then just use Microsoft's identity cookie mechanism and embed the protected API endpoints in the BFF so they can be accessed with just the cookie. No tokens needed.

I would start with that and maybe at a later stage look at IdentityServer when more applications come in play and/or the API needs to be external. I've created an example here (my personal GitHub account) that shows you what I mean. It uses React as a front-end but the principle is the same. Please understand that this all Microsoft, there are no Duende products involved. So we don't support this here.

schlechtOptimiziert commented 3 months ago

Thank you very much, this was helpful<3.

I understand that this template is not the desired way to do things. It sounds like shooting with cannons at birds, if I my say so.

If this template is "just" overkill it should still work, right? And yes it works locally but not in docker. The error is not really helping as it just says something is null. image Overall I don't understand the error encountered. Would be great to understand what the problem is and probably there is an quick and dirty way to resolve this?

RolandGuijt commented 3 months ago

It's not just overkill. It is just the wrong way to use IdentityServer. It is not intended to be used in this way and there's also no need to add the complexity in this scenario.

I've tried your solution and even outside of Docker it doesn't work correctly. Please refer to the tips I gave above, I wouldn't spend more time on the application in the state it is in now.