Class StandardBearerEvents
The default JwtBearerEvents: failures are logged and answered with a 401 status, and the bearer token is kept in the BootstrapContext of the validated identity.
public class StandardBearerEvents : JwtBearerEvents
- Inheritance
-
StandardBearerEvents
- Inherited Members
Constructors
StandardBearerEvents(ILogger<StandardBearerEvents>)
The default JwtBearerEvents: failures are logged and answered with a 401 status, and the bearer token is kept in the BootstrapContext of the validated identity.
public StandardBearerEvents(ILogger<StandardBearerEvents> logger)
Parameters
loggerILogger<StandardBearerEvents>The logger.
Methods
AuthenticationFailed(AuthenticationFailedContext)
Logs the exception (or, for a token whose audience is not accepted, the received and expected audiences), the reason why the authentication failed, fails the authentication and answers with a 401 status.
public override Task AuthenticationFailed(AuthenticationFailedContext context)
Parameters
contextAuthenticationFailedContextThe authentication failure context.
Returns
- Task
A completed task.
Challenge(JwtBearerChallengeContext)
Answers the challenge with a 401 status and a ProblemDetails body (application/problem+json). For an expired token, the x-token-expired header gives the expiration date; for a token issued for another audience, the detail names the rejected audience.
public override Task Challenge(JwtBearerChallengeContext context)
Parameters
contextJwtBearerChallengeContextThe challenge context.
Returns
- Task
A task that completes when the response is written.
MessageReceived(MessageReceivedContext)
Invoked when a protocol message is first received.
public override Task MessageReceived(MessageReceivedContext context)
Parameters
contextMessageReceivedContext
Returns
TokenValidated(TokenValidatedContext)
Saves the access token, read from the Authorization header, in the BootstrapContext of the identity.
The authentication fails with a 401 status when the header does not carry a Bearer token, or when the claims filler is enabled
(LoadClaimsFromClaimsFillerProvider) and no claim identifying the user (see ClaimsIdentifierOption) is in the token.
public override Task TokenValidated(TokenValidatedContext context)
Parameters
contextTokenValidatedContextThe token validated context.
Returns
- Task
A completed task.