title: Zuul spring security and adding Additional Params in Request
body: <p>I am building Microservices using Spring Microservices, I have 2 questions related to that.<br><br>1. I have spring security in the Api Gateway i.e <strong>Zuul server</strong>, now Zuul is not forwarding any request if I have already read the request from the stream once to Authenticate(to get username/pass from POST Request) <br>
  <code>new ObjectMapper().readValue(request.getInputStream(), UserDto.class);</code> 
  <br><strong>How can I read the request and then again forward the same request to Downstream services?</strong><br><br>
  2. Zuul is not forwarding <strong>request.setAttribute()</strong> to Downstream services, so a workaround is to use <strong>ctx.addZuulRequestHeader</strong>, which is making <code>Request Header</code> too huge, How can I acheive <strong>request.setAttribute</strong> and get in downstream services.</p>
  
  <pre><code> public Authentication getAuthentication(HttpServletRequest request) {
      final String token = request.getHeader(AUTH_HEADER_NAME);
      logger.info("token="+token);
      if (token != null) {
          logger.info("Entering getAuthentication");
          final UserToken userInfo = tokenHandler.validateToken(token);
          if (userInfo != null
                  &amp;&amp; token.equals(String.valueOf(redisUtility.getValue(userInfo.getUsername()+"_"+userInfo.getUniqueId())))) {
              logger.info("Validating token key="+userInfo.getUsername()+"_"+userInfo.getUniqueId());
              User user=userDetailsService.loadUserByUsername(userInfo.getUsername());
              if(user!=null &amp;&amp; user.getUsername().equals(userInfo.getUsername())
                  &amp;&amp; user.getLastPasswordResetTime()&lt;userInfo.getCreatedTime()){
                  request.setAttribute("username",user.getUsername());//**Not able to fetch this in Downstream services**
                  logger.info("Token Authenticated for User "+user.getUsername());
                  return new UserAuthentication(user);
              }
          } 
      }
      return null;
  }
  
  
    public class SimpleFilter extends ZuulFilter {
  
        private static Logger log = LoggerFactory.getLogger(SimpleFilter.class);
  
        @Override
        public String filterType() {
          return "pre";
        }
  
        @Override
        public int filterOrder() {
          return 1;
        }
  
        @Override
        public boolean shouldFilter() {
          return true;
        }
  
        @Override
        public Object run() {
          RequestContext ctx = RequestContext.getCurrentContext();
          HttpServletRequest request = ctx.getRequest();
          request.setAttribute("test", "test");// Not able to get this in services
          log.info(String.format("%s request to %s", request.getMethod(), request.getRequestURL().toString()));
  
          return null;
        }
  
   @Bean
    public SimpleFilter simpleFilter() {
      return new SimpleFilter();
    }
  
  @RequestMapping(value = "/test/avl",method=RequestMethod.POST)
    public String test(HttpServletRequest request) {
      System.out.println(request.getAttribute("test")+"");
      return "Spring in Action";
    }
  </code></pre>