1

I use the keycloak docker image to secure a node.js app. When I am running my node.js app on my local machine everything works as expected. But when I run my app in a docker container I get always Access denied. I can step into the conatiner and reach the keycloak from there (by using the IP of the localhost, I forwarded the ports of keycloak to the host or by calling it by the container name, I added the node.js app to the keycloak network).

This is how my keycloak.json looks

{
"realm": "spectraSelect",
"bearer-only": true,
"auth-server-url": "http://10.49.30.78:8080/auth",
"ssl-required": "none",
"resource": "node-server",
"confidential-port": 0
}

Is there any way to debug the keycloak-connect. I tried already everything, I running out of ideas :(.

Love and Peace, Philipp

Phil
  • 11
  • 1
  • Enable the logs for your node.js app in the container, then you'll see what might be happening. See also the logs for KC server. What do you have? – Aritz May 31 '18 at 06:17
  • 1
    Hi, the I solved it. The problem was the following: when I requested my token I used http://localhost:8080/auth. This is obviously wrong. I had to use http://10.49.30.78:8080/auth to get the token, which makes also sense. – Phil May 31 '18 at 07:54
  • I have the same problem. Phil, could you please elaborate a bit, how did you solve your problem. – Lazar Nikolic Aug 27 '18 at 07:36
  • 1
    The point that I missed was that I also had an angular frontend. So the following happend I set my keycloak on the server as mentioned (http://10.49.30.78:8080/auth), but I stiiled used localhost in the angular app. And this doesn't work, because the node.js expecting an token signed by 10.49.30.78 and not by localhost. I hope this helps, otherwise write me. – Phil Aug 28 '18 at 08:30

0 Answers0