title: .NET Core 6 Minimal API - check JWT authorize status
body: <p>I am experimenting with .Net Core 6 Minimal APIs and using JWT authorization.</p>
  <p>I've set up the 'standard' JWT builder service to add authentication and authorization</p>
  <pre><code>    builder.Services.AddAuthentication(o =&gt;
  {
      o.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
      o.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
      o.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
  }).AddJwtBearer(o =&gt;
  {
      o.TokenValidationParameters = new TokenValidationParameters
      {
          ValidateIssuer = true,
          ValidateAudience = true,
          ValidateLifetime = true,
          ValidateIssuerSigningKey = true,
          ClockSkew = TimeSpan.Zero,
          ValidIssuer = builder.Configuration[&quot;Jwt:Issuer&quot;],
          ValidAudience = builder.Configuration[&quot;Jwt:Audience&quot;],
          IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(builder.Configuration[&quot;Jwt:Key&quot;]))
      };
  });
  
  builder.Services.AddAuthorization();
  
  app.UseAuthentication();
  app.UseAuthorization();
  </code></pre>
  <p>That works great and I can issue valid JWTs and then decorate endpoints with [Authorize] and get a 401 if the JWT is not valid.</p>
  <p>What I want to do next is to use an endpoint without Authorize but then check the JWT and have some logic depending on its validity. Can I use the DI services (I'm not sure if these are triggered if the endpoint is not decorated [Authorize]) or do I need to manually check the JWT outside of the middleware?</p>
  <p>Thanks</p>