예제 #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);
        }
예제 #2
0
        protected override Task HandleSignOutAsync(AuthenticationProperties properties)
        {
            AuthenticationLogMessages.SignOutHandling(Logger);

            Response.Cookies.Delete(Options.TokenHeaderAndPayloadCookieKey);
            AuthenticationLogMessages.AuthenticationTokenHeaderAndPayloadDetached(Logger, Options.TokenSignatureCookieKey);
            Response.Cookies.Delete(Options.TokenSignatureCookieKey);
            AuthenticationLogMessages.AuthenticationTokenSignatureDetached(Logger, Options.TokenSignatureCookieKey);

            if (properties.RedirectUri is string)
            {
                AuthenticationLogMessages.IssuingSignOutRedirect(Logger, properties.RedirectUri);
                Response.Redirect(properties.RedirectUri);
            }

            AuthenticationLogMessages.SignOutHandled(Logger);
            return(Task.CompletedTask);
        }