jwt-dotnet/jwt

Improve the integration with AspNetCore

drusellers opened this issue · 6 comments

I would love to see the various event methods on JwtAuthenticationOptions be exposed via the EventsType model like other Authentication providers. This would allow me to then pull in other items from my container and would allow me to build out a richer set of logging, rather than only having the items that are exposed in the current methods. These one off event methods should still be exposed, so this is adding another method that would allow developers to hook into the IoC container.

Here is an example OAuthEvents class - https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.authentication.oauth.oauthevents?view=aspnetcore-6.0

One element that I would really like to have access to is the HttpContext. I'm currently seeing some requests with empty auth headers and I'd be curious to understand the underlying HTTP request a bit better.

Side Note: Today I learned that this snippet of code for logging was "erasing" my successful login. 😂

options.OnSuccessfulTicket += (logger, ticket) =>
{
  logger.LogInformation("OnSuccessfulTicket");
  return AuthenticateResult.NoResult();
};

If you set the loglevel to debug you'll get more details from the authentication checks.

I def had it set full bore. I just wasn't reading it quite right. :) I had a bad mental context.

Whether it is planned to be added to the target platforms .net 6 for JWT
Extensions.AspNetCore and JWT
Extensions.DependencyInjection?

@MaxLevs JWT already includes net6, the extensions target netstandard2.0 which also works with net6. Is there a particular reason to specify net6 explicitly?
I can do that (or accept a pull request), but first would like to understand the rationale behind the proposed change.