title: Use Windows Auth to authenticate user and then generate JWT in ASPNET Core 2.1
body: <p>I have an ASP.NET Core 2.1 WebApi, in which I have implemented JWT authentication. The user calls <code>api/authentication/authenticate</code>, passes their username/password in the message body, and gets back a JWT in return which they then use to access the service.</p>
  
  <p>I also need the API to accept Windows authentication -- the user will call <code>api/authentication/windows</code> passing no user information, the service will check they are in the list of authorized users as listed in the web.config file (if I am hosting in IIS). If so, return a JWT token and the user can use that to access the service. </p>
  
  <p>Currently I'm thinking about this...</p>
  
  <ol>
  <li>The <code>api/authentication/windows</code> method will get the username from the request</li>
  <li>Check the username against the list of authorized users. If they are on it, return a token. If not, go to (3)</li>
  <li>Check against any groups in the authorized users list. If they are a member, return a token. If not, return a 401 Unauthorized error</li>
  </ol>
  
  <p>Is this the correct way to approach this? </p>
  
  <p>Very similar (unanswered) question here: <a href="https://stackoverflow.com/questions/54045940/generate-jwt-token-on-successful-authentication-with-windows-authentication">Generate JWT token on successful authentication with Windows Authentication</a></p>