Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid redirect to another host with Zuul?

I tried to play with Zuul, a reverse proxy used in Spring Cloud Netflix. I've started a project from a tutorial found on spring blog (https://spring.io/blog/2015/02/03/sso-with-oauth2-angular-js-and-spring-security-part-v)

I'm not sure however that I correctly understood the role of Zuul.

If I go to localhost:8080/login, I thought that Zuul would have proxified my request so that I stay on localhost:8080 But I got a 302 redirect to localhost:9999/uaa/login.

The zuul routes configured are as follows :

zuul: routes: resource: path: /resource/** url: http://localhost:9000/resource login: path: /login/** url: http://localhost:9999/uaa/login user: path: /user/** url: http://localhost:9999/uaa/user auth: path: /auth/** url: http://localhost:9999/uaa/

Is it ever possible to always stay on localhost:8080 (which is what I thought Zuul was supposed to do) ?

The full project is available on github so it is possible to run it locally : https://github.com/hlassiege/oauth-social-zuul

like image 940
Hugo Lassiège Avatar asked Feb 11 '23 12:02

Hugo Lassiège


1 Answers

The redirect is actually caused by Spring Security, not by the Zuul part of the configuration, so irrespective of the Zuul configuration, the Security features are going to stop you getting to anything before you have authenticated. The server at "localhost:9999/uaa" is an OAuth2 authorization server. It plays a role like Github or Facebook would in the SSO scenario ("Login with Facebook" etc.). You wouldn't want to proxy those calls because the server handles its own protocols. If you didn't have OAuth2 SSO then you could proxy calls to anything you wanted.

like image 135
Dave Syer Avatar answered Feb 13 '23 05:02

Dave Syer