title: zuul : Bearer authentication not accepted
body: <p>I have an application trying to call a RESTApi under a Zuul proxy.</p>
  
  <p>The application have a valid jwt token given by the OAuth2 server.
  I had the token in a bearer authorization in the header but I have an <strong>401</strong> ("Full authentication is required to access this resource") response from the zuul server.</p>
  
  <p>My zuul configuration :</p>
  
  <pre><code>eureka:
      client:
          registerWithEureka: true
          fetchRegistry: true
          serviceUrl:
              defaultZone: http://localhost:8761/eureka/
      instance:
          leaseRenewalIntervalInSeconds: 10
          statusPageUrlPath: ${management.context_path}/info
          healthCheckUrlPath: ${management.context_path}/health
  
  server:
      port: 80
  management:
      port: 81
      context_path: /admin
  
  security:
      sessions: stateless
        # Disable Spring Boot basic authentication
      basic:
          enabled: false
  
  endpoints:
      restart:
          enabled: true
      shutdown:
          enabled: true
      health:
          sensitive: false
  
  # The OAuth2 server definition that would be used to send the authorization requests to
  authserver:
      hostname: localhost
      port: 9000
      contextPath: uaa
  
  spring:
      oauth2:
          resource:
              userInfoUri: http://${authserver.hostname}:${authserver.port}/${authserver.contextPath}/user
              jwt.key-uri: http://${authserver.hostname}:${authserver.port}/${authserver.contextPath}/oauth/token_key
              preferTokenInfo: false
  
      output:
          ansi:
              enabled: ALWAYS
  </code></pre>
  
  <p>The main zuul file :</p>
  
  <pre><code>@SpringBootApplication
  @EnableZuulProxy
  @EnableResourceServer
  public class ZuulApplication {
  
      public static void main(String[] args) {
          new SpringApplicationBuilder(ZuulApplication.class).web(true).run(args);
      }
  }
  </code></pre>
  
  <p>The zuul security configuration file :</p>
  
  <pre><code>@Configuration
  public class WebSecurityConfiguration extends ResourceServerConfigurerAdapter  {
  
      @Override
      public void configure(HttpSecurity http) throws Exception {
          http
                  .csrf().disable()
                  .exceptionHandling()
                  .and()
                      .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
                  .and()
                  .authorizeRequests()
                      .antMatchers("/admin/trace").permitAll()
                      .anyRequest().authenticated()
                  ;
      }
  
  }
  </code></pre>
  
  <p>The call of the restApi:</p>
  
  <pre><code>        final String access_token = (String) httpSession.getAttribute(OAuthComponent.HTTPSESSION_OAUTH_ACCESS_TOKEN);
  
          final MultiValueMap&lt;String, String&gt; headers = new LinkedMultiValueMap&lt;&gt;();
          headers.add("Authorization", "Bearer " + access_token);
          headers.add("Content-Type", "application/json");
  
          final HttpEntity&lt;Object&gt; request = new HttpEntity&lt;&gt;(searchParams,headers);
  
          return restOperations.postForObject("http://localhost/ms-arbre-recherche/utilisateur/search", request, Object.class);
  </code></pre>
  
  <p>I use spring cloud Brixton SR2 and spring boot 1.4.0RC1.</p>