title: Zuul reverse proxy with Keycloak server
body: <p>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, <code>http://localhost:8765/organization/organizations</code> returns the JSON with all the organizations. </p>
  
  <p>However, now I want to integrate a Keycloak SSO (OAuth2) server for authorization purposes. I have added the <a href="https://keycloak.github.io/docs/userguide/keycloak-server/html/ch08.html#spring-security-adapter" rel="noreferrer">Spring Security adapter</a> in my organization service and configured it to authenticate in <code>http://localhost:8080/auth</code>. Everything goes well, except that zuul performs a redirection instead of proxying. So when authentication is successful, I get redirected to <code>http://localhost:8083/organizations</code> instead of <code>http://localhost:8765/organization/organizations</code>. Here there are my browser requests:</p>
  
  <p><a href="https://i.stack.imgur.com/5tmAI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5tmAI.png" alt="enter image description here"></a></p>
  
  <p>That's because the keycloak adapter creates a token verification endpoint in the <code>http://localhost:8083/sso/login</code>, 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 <code>/organization</code> path, so the end url being loaded is <code>http://localhost:8083/organizations</code>. But I would like the first requested url to be loaded instead. </p>
  
  <p>Which choice do I have?</p>