0

I have a Netflix Zuul server receiving all HTTP requests and forwarding them to my microservice.

The underlying microservice authenticates users through Facebook oauth API. I receive the user data from Facebook API and I authenticate the user programmatically:

public Authentication login(String username, String password) {
    UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(username, password);
    Authentication result = authenticationManager.authenticate(token);
    SecurityContextHolder.getContext().setAuthentication(result);
    return result;
}

With Zuul in front this doesn't work. I think it sets up the session in the microservice environment, but never extends it to Zuul. It works fine when requests go straight to microservice.

What I've done:

I cleared the sensitiveHeaders property in my application.properties: zuul.routes.[SERVICE_NAME].sensitiveHeaders=, but it's meant to work the other way around I think.

How do I setup a session with Zuul?

Edit:

My Zuul configuration:

# Zuul proxy
zuul.add-host-header=true
zuul.routes.httpbin.path=/**
zuul.routes.httpbin.serviceId=httpbin
zuul.routes.httbin.sensitiveHeaders=

httpbin.ribbon.listOfServers=http://localhost:8090

ribbon.eureka.enabled=false
  • You may have to include more details about how you have Zuul configured. For example, do you have the following in your config. proxy: auth: routes: my-service: oauth2 – Faron Sep 03 '17 at 18:01
  • I handle all the oauth2 redirects myself in my custom controller and then setup the session myself, I tried it but nothing, not sure if this out of the box `oauth2` helps? –  Sep 03 '17 at 18:12
  • See if this answer is what you are looking for: https://stackoverflow.com/a/34444279/252344 – Faron Sep 03 '17 at 18:16
  • Not really, I'm not hosting oauth2 authorization server and I don't have an endpoint for giving out tokens. I simply setup a spring security session. In the end I'd just want to see `JSESSIONID` in my cookies, but currently it doesn't get set. –  Sep 03 '17 at 19:24

0 Answers0