Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ public async Task AuthenticateAsync(AuthenticationRequest authenticationRequest)
// set the ClaimsPrincipal for the HttpContext; authentication will take place against this object
connection.HttpContext.User = principal;
return;
} else if (_jwtBearerAuthenticationOptions.EnableJwtEvents) {
// If JWT events are enabled, trigger the AuthenticationFailed event
var exception = tokenValidationResult.Exception ?? new SecurityTokenValidationException($"The TokenHandler: '{tokenHandler}', was unable to validate the Token.");
var failedResult = await TriggerAuthenticationFailedEventAsync(connection.HttpContext, options, exception, scheme).ConfigureAwait(false);
if (failedResult.Handled && failedResult.Success) {
connection.HttpContext.User = failedResult.Principal!;
return;
}
}
} catch (Exception ex) {
// If JWT events are enabled, trigger the AuthenticationFailed event
Expand Down
Loading
Loading