Ejemplo n.º 1
0
        public async Task Invoke(HttpContext context)
        {
            using (RequestServicesContainer.EnsureRequestServices(context, _services))
            {
                AuthenticationHandler <TOptions> handler = CreateHandler();
                await handler.Initialize(Options, context);

                try
                {
                    if (!await handler.InvokeAsync())
                    {
                        await _next(context);
                    }
                }
                catch (Exception)
                {
                    try
                    {
                        handler.Faulted = true;
                        await handler.TeardownAsync();
                    }
                    catch (Exception)
                    {
                        // Don't mask the original exception
                    }
                    throw;
                }
                await handler.TeardownAsync();
            }
        }
Ejemplo n.º 2
0
 public static object RegisterAuthenticationHandler(this HttpRequest request, AuthenticationHandler handler)
 {
     var chained = request.Get<AuthenticateDelegate>(Constants.SecurityAuthenticate);
     var hook = new Hook(handler, chained);
     request.Set<AuthenticateDelegate>(Constants.SecurityAuthenticate, hook.AuthenticateAsync);
     return hook;
 }
        public async Task Invoke(HttpContext context)
        {
            using (RequestServicesContainer.EnsureRequestServices(context, _services))
            {
                AuthenticationHandler <TOptions> handler = CreateHandler();
                await handler.Initialize(Options, context);

                if (!await handler.InvokeAsync())
                {
                    await _next(context);
                }
                await handler.TeardownAsync();
            }
        }
Ejemplo n.º 4
0
        private static void OnSendingHeaderCallback(object state)
        {
            AuthenticationHandler handler = (AuthenticationHandler)state;

            handler.ApplyResponse();
        }
Ejemplo n.º 5
0
 public Hook(AuthenticationHandler handler, AuthenticateDelegate chained)
 {
     _handler = handler;
     Chained = chained;
 }