You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
keycloak.protect() returns 403 when Backend runs in container
#38469
I’m running into an issue with protected routes in a Node.js/Express app using keycloak-connect.
Setup:
• Keycloak is installed in a container (running on a Synology NAS via Portainer)
• IoT field devices (embedded systems)
• Backend is a REST API built with Node.js/Express
Flow:
1. IoT devices request a token from Keycloak using grant_type=client_credentials
2. Devices send a request to the Backend with the token in the header
3. The Backend uses keycloak.protect() to secure the route and validate the token
Issue:
• Everything works correctly when the Backend is running on my local machine.
• When I move the Backend into a container, the same request results in a 403 Forbidden.
** Notes**:
• Networking is configured so that the Backend container can reach the Keycloak container and works properly.
• If I remove the keycloak.protect() it works fine in the container!
• Keycloak host url is set as http://keycloak:8080. I did try http://keycloak:8080/auth but no improvements.
Has anyone run into a similar issue? Could this be related to how the Keycloak adapter resolves the hostname or handles requests inside containers?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi all,
I’m running into an issue with protected routes in a Node.js/Express app using keycloak-connect.
Setup:
• Keycloak is installed in a container (running on a Synology NAS via Portainer)
• IoT field devices (embedded systems)
• Backend is a REST API built with Node.js/Express
Flow:
1. IoT devices request a token from Keycloak using grant_type=client_credentials
2. Devices send a request to the Backend with the token in the header
3. The Backend uses keycloak.protect() to secure the route and validate the token
Issue:
• Everything works correctly when the Backend is running on my local machine.
• When I move the Backend into a container, the same request results in a 403 Forbidden.
** Notes**:
• Networking is configured so that the Backend container can reach the Keycloak container and works properly.
• If I remove the keycloak.protect() it works fine in the container!
• Keycloak host url is set as http://keycloak:8080. I did try http://keycloak:8080/auth but no improvements.
Has anyone run into a similar issue? Could this be related to how the Keycloak adapter resolves the hostname or handles requests inside containers?
Thanks in advance!
All reactions