NikiforovAll / keycloak-authorization-services-dotnet

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

Documentation improvement: Connect from containerized Api #115

Open TheAutomaTom opened 3 months ago

TheAutomaTom commented 3 months ago

@NikiforovAll can we please get some advice on how to get a Web Api debugging in the default Docker launch profile to connect to a Keycloak running also running on a local (separate) container?

I hope this simple repo with keycloak export and postman calls may be a positive contribution to the effort: TheAutomaTom/Lab.Keycloak

Original discussion topic for reference:

Is there any documentation on how to run a web api in docker, connecting to Keycloak in a separate docker container?

When I try, the exception begins with: Warning: Unable to verify the first certificate.

And, at the bottom of the response I see: WWW-Authenticate: Bearer error="invalid_token", error_description="The issuer 'http://localhost:8080/realms/my-realm' is invalid"

This is my config:

"Keycloak": { "realm": "my-realm", "resource": "my-client", //"auth-server-url": "http://localhost:8080/", // for http or https launch profiles "auth-server-url": "http://host.docker.internal:8080/", "ssl-required": "none", "verify-token-audience": false, "credentials": { "secret": "my-secret" } },

This solution works fine in http and https launch profiles.

I realize this isn't specifically related to your nuget, but I have not found any docs about local development covering this. Thanks!