예제 #1
0
        public static Task OnAuthenticationFailed(AuthenticationFailedContext context)
        {
            var logger = GetLogger(context.HttpContext.RequestServices);

            AuthenticationLogMessages.AuthenticationFailureHandling(logger);

            var options = context.HttpContext.RequestServices.GetRequiredService <IOptions <ApiAuthenticationOptions> >().Value;

            context.Response.Cookies.Delete(options.TokenHeaderAndPayloadCookieKey);
            AuthenticationLogMessages.AuthenticationTokenHeaderAndPayloadDetached(logger, options.TokenSignatureCookieKey);
            context.Response.Cookies.Delete(options.TokenSignatureCookieKey);
            AuthenticationLogMessages.AuthenticationTokenSignatureDetached(logger, options.TokenSignatureCookieKey);

            AuthenticationLogMessages.AuthenticationFailureHandled(logger);
            return(Task.CompletedTask);
        }