Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set AuthenticationType of JwtBearer TokenValidationParameters #111

Merged
merged 1 commit into from
Jul 11, 2024

Conversation

DanielEgbers
Copy link

This PR fixes HttpContext.User.Identity.AuthenticationType not being set correctly when authenticating with JwtBearer.

Given the following endpoint and appsettings:

app.MapGet("api/me", (ClaimsPrincipal user) =>
{
    return new
    {
        user?.Identity?.AuthenticationType
    };
})
"Authentication": {
  "JwtBearer": {
      "SchemeName": "my_JwtBearer_scheme",
      ...
  },
  "ApiKey": {
      "SchemeName": "my_ApiKey_scheme",
      ...
  },
  "Basic": {
      "SchemeName": "my_Basic_scheme",
      ...
  }
}

Authenticating with Basic will return { "authenticationType": "my_Basic_scheme" }
and authenticating with ApiKey will return { "authenticationType": "my_ApiKey_scheme" }.
However authenticating with JwtBearer will currently return { "authenticationType": "AuthenticationTypes.Federation" } instead the expected { "authenticationType": "my_JwtBearer_scheme" }.

@DanielEgbers DanielEgbers changed the base branch from master to develop July 10, 2024 21:58
@marcominerva marcominerva merged commit c14fc95 into marcominerva:develop Jul 11, 2024
2 of 3 checks passed
@marcominerva
Copy link
Owner

Thank you for your contribution @DanielEgbers. The fix has been merged and published on NuGet (v2.0.21).

@DanielEgbers DanielEgbers deleted the fix-jwt-auth-type branch July 12, 2024 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants