title: Unreachable security context using Feign RequestInterceptor
body: <p>The goal is to attach some data from security context using RequestInterceptor, but the problem, that the calling <code>SecurityContextHolder.getContext().getAuthentication()</code> always returns null even though it is not null (I am sure 100%). </p>
  
  <p>As I understand that's because the Interceptor is created and is being run in other thread.</p>
  
  <p>How could I solve this problem and get actual data from security context?</p>
  
  <p>My service:</p>
  
  <pre><code>@FeignClient(value = "api", configuration = { FeignConfig.class })
  public interface DocumentService {
  
      @RequestMapping(value = "/list", method = RequestMethod.GET)
       DocumentListOperation list();
   }
  </code></pre>
  
  <p>My FeignConfig class:</p>
  
  <pre><code>@Bean
  public RequestInterceptor requestInterceptor() {
      return new HeaderInterceptor(userService);
  }
  
  public class HeaderInterceptor implements RequestInterceptor {
  
      private UserService userService;
  
      public HeaderInterceptor(UserService userService) {
          this.userService = userService;
      }
  
      @Override
      public void apply(RequestTemplate requestTemplate) {
          Authentication a = SecurityContextHolder.getContext().getAuthentication()
  
          requestTemplate.header("authentication", a.toString());
      }
  }
  </code></pre>