title: How to implement Windows Authentication in a .Net Core API Gateway using Ocelot so that all downstream services can access IWindowsPrincipal?
body: <h2>Background</h2>
  <p>I have two microservices that require access to IWindowsPrincipal of the calling user.
  I am writing an API Gateway using .Net Core 3.1 that will act as a reverse proxy for these services.
  I have configured Authentication and Authorization in the API Gateway as follows:</p>
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      services.AddCors(options =&gt;
      {
          options.AddPolicy(&quot;All allowed&quot;,
              builder =&gt;
              {
                  builder
                      .AllowAnyOrigin()
                      .AllowAnyMethod()
                      .AllowAnyHeader();
              });
      });
  
      services.AddAuthentication(NegotiateDefaults.AuthenticationScheme)
          .AddNegotiate();
      services.AddAuthorization();
  
      services.AddControllers();
      services.AddHttpForwarder();
      services.AddOcelot();
      services.AddSwaggerForOcelot(_configuration);
  }
  
  public void Configure(IApplicationBuilder app)
  {
      app.UseCors(&quot;All allowed&quot;);
  
      app.UseRouting();
  
      app.UseAuthentication();
      app.UseAuthorization();
  
      app.UseEndpoints(endpoints =&gt;
      {
          endpoints.MapControllers();
      });
  
      app.UseSwaggerForOcelotUI(options =&gt;
      {
          options.PathToSwaggerGenerator = &quot;/swagger/docs&quot;;
      });
  
      app.UseOcelot();
  }
  </code></pre>
  <h2>Requirement</h2>
  <p>I would like to access the calling user's identity using HttpContext.User.Identity
  in the method of the microservices.</p>
  <h2>Actual Result</h2>
  <p>In the methods of the microservices, HttpContext.User.Identity.IsAuthenticated is false and the identity information is empty.</p>
  <h2>Question</h2>
  <p>Is there a way to configure Ocelot in the gateway so that it will Challenge the caller if necessary receive Windows Authentication information and pass it on to the microservices?
  If this is not possible, is the recommend way to achieve my goal, to perform implement Windows Authentication in each of the microservices?
  Isn't Ocelot supposed to allow me to handle Authentication in one place for all microservices?</p>
  <h2>Follow on Question 1</h2>
  <p>Ocelot's documentation refers to Authentication using a JWT.
  Should I conclude that Ocelot only provides JWT configuration?</p>
  <h2>Follow on Question 2</h2>
  <p>I have read a little about Yarp (<a href="https://microsoft.github.io/reverse-proxy/" rel="nofollow noreferrer">https://microsoft.github.io/reverse-proxy/</a>)
  Should I be using Yarp instead of Ocelot to achieve my goal?</p>