I'm configuring a Spring Cloud (Angel.SR6) application using the Zuul reverse proxy utility, in order to hide the internal service ports. My zuul (edge) service is published in the 8765 port and my organizations service is in the 8083 one. Everything goes smoothly when I access the application with no security, http://localhost:8765/organization/organizations
returns the JSON with all the organizations.
However, now I want to integrate a Keycloak SSO (OAuth2) server for authorization purposes. I have added the Spring Security adapter in my organization service and configured it to authenticate in http://localhost:8080/auth
. Everything goes well, except that zuul performs a redirection instead of proxying. So when authentication is successful, I get redirected to http://localhost:8083/organizations
instead of http://localhost:8765/organization/organizations
. Here there are my browser requests:
That's because the keycloak adapter creates a token verification endpoint in the http://localhost:8083/sso/login
, from which it performs a redirection to the authorization server in order to validate the token. When authorization server acknowledges it, a redirection is sent to the organization service, with the /organization
path, so the end url being loaded is http://localhost:8083/organizations
. But I would like the first requested url to be loaded instead.
Which choice do I have?
/auth/realm/master?redirectUri=http://localhost:8083/sso/login
. So a redirect is performed by the SSO server to that url, which also redirects to the finalhttp://localhost:8083/organizations
path. A solution would be to secure only the zuul service, so I would have every request redirected to zuul itself, but that would involve leaving the rest of the services exposed. – Complemental