NikiforovAll / keycloak-authorization-services-dotnet

Authentication and Authorization with Keycloak and ASP.NET Core 🔐
https://nikiforovall.github.io/keycloak-authorization-services-dotnet/
MIT License
480 stars 113 forks source link

Support calls from Docker to Host #144

Open rosieks opened 1 month ago

rosieks commented 1 month ago

I have service hosted on docker that obtain token from keycloak. Later this service calls my local project with that token and it fails. It's because issuer is set to host.docker.internal, while my app expect it to be localhost based on Authority property. It would be nice if WithReference could add both issuers (ContainerHost,Host) to environment variable and then AddKeycloakWebApiAuthentication consume it and add those as ValidIssuers

NikiforovAll commented 1 month ago

Sounds like a great feature for local development. Would you like to contribute?

rosieks commented 1 month ago

Actually I found that setting such variables in keycloak makes it work:

    .WithEnvironment("KC_HOSTNAME", "localhost") 
    .WithEnvironment("KC_HOSTNAME_BACKCHANNEL_DYNAMIC","true")

I wonder which way is better

NikiforovAll commented 1 month ago

I think env variables are a great way to control this one. We can still add them to Keycloak.Aspire package